![]() |
![]() |
#1 (permalink) |
Upright
Location: PVB, FL
|
VB Question
I am having a difficult time with something that must be really simple - I just have no background with VB.
I have a list box that I populated with the NAMES of certain items. I now want to select the item (not the name). I am a little more than frustrated... Is there anyone who can help with this? |
![]() |
![]() |
#3 (permalink) |
Crazy
Location: dfw - texas
|
selection in a simple listbox is controlled by the "listindex" property. it's zero-based, so the first item in the list is listindex = 0. if no items in the list are selected, listindex = -1.
hope it helps!
__________________
Depression is just anger without enthusiasm. It’s having an empty beer bottle but no one to throw it at. |
![]() |
![]() |
#5 (permalink) |
Devils Cabana Boy
Location: Central Coast CA
|
create a form with a listbox (list1) a label (label1) and enter the code
Private Sub Form_Load() List1.AddItem "test1" List1.AddItem "test2" List1.AddItem "test3" List1.AddItem "test4" List1.AddItem "test5" ' this will add 5 entries into the list box End Sub Private Sub List1_Click() Label1.Caption = "the item you selected is: " & List1.List(List1.ListIndex) & Chr(10) & Chr(13) & " Its index associated with it is: " & List1.ListIndex 'on the event that the list box is clicked, it will change the caption of the label using the listindex of list1. 'CHR(10) & CHR(13) is a 'return' End Sub this should give you a decent understanding of the list box.
__________________
Donate Blood! "Love is not finding the perfect person, but learning to see an imperfect person perfectly." -Sam Keen Last edited by Dilbert1234567; 09-19-2004 at 12:58 PM.. |
![]() |
Tags |
question |
Thread Tools | |
|
|