473,408 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

listbox- how to get first item only

I have a list box where the user might need to select two items which builds
up an sql string. Another part of the function only requires the first item.

here is the code :
For Each varItems In Me.ListDOS.ItemsSelected

If strMods = vbNullString Then
strMods = "=" & """" & Me.ListDOS.Column(1, varItems) & """"
Else
strMods = "=" & """" & Me.ListDOS.Column(1, varItems) & """"
End If
Next varItems

I am not sure how to amend it so that it reaches only the first item, stores
it to strMods and then drops out of the loop.

regards in advance.

Peter
Nov 13 '05 #1
1 2409
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

' this is a very easy solution
' probably a much more elegant one, that I can't think of

For Each varItems In Me.ListDOS.ItemsSelected
If strMods = vbNullString Then
strMods = "=" & """" & Me.ListDOS.Column(1, varItems) & """"
Else
strMods = "=" & """" & Me.ListDOS.Column(1, varItems) & """"
End If

exit for

Next varItems

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQUcyjIechKqOuFEgEQL6cQCeOLdsBH9G+0KlV0bKYm+Dxz XNHvcAoMXX
EOWcSgKVvpX4nBXh9slLg+0x
=MOof
-----END PGP SIGNATURE-----
Peter Bailey wrote:
I have a list box where the user might need to select two items which builds
up an sql string. Another part of the function only requires the first item.

here is the code :
For Each varItems In Me.ListDOS.ItemsSelected

If strMods = vbNullString Then
strMods = "=" & """" & Me.ListDOS.Column(1, varItems) & """"
Else
strMods = "=" & """" & Me.ListDOS.Column(1, varItems) & """"
End If
Next varItems

I am not sure how to amend it so that it reaches only the first item, stores
it to strMods and then drops out of the loop.


Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fieldmedic | last post by:
I'm attempting to get an arraylist to display in a Listbox (listbox2). The arraylist is created from selections in a different listbox (listbox1). The 1st listbox has a selection mode of...
5
by: Brian | last post by:
Hi, All, I'm using MS.net 2003 and using a windows.forms.listbox control for my window application but I don't know why the Horizontal Scrollbar could NOT be shown even if I set...
17
by: amber | last post by:
Hello. Can someone tell me what I may be doing wrong here? I'm using the code (lboxRP is a listbox): Dim newRPindex As Integer newRPindex = Me.lboxRP.FindString(RP)...
4
by: Alienz | last post by:
I have a subform where I have a subform with 20 options to select from. When I set the multiselect property to simple and select multiple options, nothing is stored. I have another table with...
9
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have...
2
by: xzzy | last post by:
I have an app that uses a listbox to display program status messages, and a public function to be used by the solution to update the listbox. I do not know how to make the listbox public so it...
1
by: Daniel | last post by:
hi, I had an asp:listbox, and everytime i click item inside, the bar automatically go to the top, is there any way to keep the scroll position? I turn on the smartNavigation, it still doesn't...
13
by: Larry Woods | last post by:
I am creating a "from-to" set of listboxes where the "left" listbox had a list of values and I want to be able to select these values, 1 at a time, and move them into a "right" listbox, removing...
3
by: Hugh O | last post by:
Hi, There is a ROW property on the Web Listbox control within VB.Net. The description states it is "The number of visible rows to display". I have tried setting this property in many different...
5
by: markr1000 | last post by:
I must have looked searched in 500+ places that showed up in Google searchs, but not one has an example of what I want to do. I have a Listbox on a User Control because I want to control the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.