well anybody know how can i get for example the second item from a listbox????????????
Printable View
well anybody know how can i get for example the second item from a listbox????????????
MsgBox List1.List(1))
syntax is
control.List(position)
position starts from 0 so, 2nd item means 1
VB Code:
msgbox Me.List1.List(1)
If you wanted to msgbox out the third item:
msgbox Me.List1.List(2)
Obviously this is assuming your list is called List1.
to get the second item from the listbox, do it like this
VB Code:
dim SecondVal As String SecondVal = list1.list(1)
to get specific values in a listbox, use the list property and supply the index number of the data you want to retrieve
the index starts with 0 so if the listbox has 5 items, the index would range from 0 to 4
or 0 to list1.ListCount - 1
ListCount returns the total number of items in your listbox
Do you mean
(The index starts at 0, so item 2 has index 1)VB Code:
MsgBox ListBox1.List(1)
Whoh, 5 similar posts in less than a minute :D
thanks...................
then can you mark this thread as resolved. just see my signature <below the line after this message> for instructions on how to do it ok.