If I am trying to select an item from listbox1 and an item from listbox2 that need to be converted to integers what do I do? I am having trouble understanding the selectItems.property

Private Sub Form_Load()
'Add ITems in the List
List1.AddItem "One"
List1.AddItem "Two"
List1.AddItem "Three"
List1.AddItem "Four"
List1.AddItem "Five"
List1.AddItem "Six"
List1.AddItem "Seven"
List1.AddItem "Eight"
List1.AddItem "Nine"
List1.AddItem "Ten"
End Sub

Private Sub List1_Click()
MsgBox "youve selected: " & List1.List(List1.ListIndex) & vbCrLf & "with an Item Index of: " & List1.ListIndex
End Sub

List1.Selected is Boolean, this will just tell you if an item is selected and returns you a boolean answer..

List1.ListIndex - this will show you what INDEX in the list what you have just selected

List1.List(List1.ListIndex) - this will show you the TEXT you have selected..

Hope you understand what i am saying... lol..

Hi jeofaries,
if I am not wrong I think there is no SelectedItems method in ListBox however List View has this method. As used by jhai_salvador, you can use ListBox1.Selected method if you want to know if the Listbox is selected.

Use

Text1.Text = List1.List(List1.ListIndex)

to show Text of selected list in Text1.

If you want to use the list as Integer then use

Dim intList as Integer
intList = List1.List(List1.ListIndex)
Text1 = intList

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.