View Full Version : Quick Question for VB6Pro
drunkmonkey
12-14-01, 07:48 PM
How do you get text from a listbox??? Like to save it or pt the text somewhere else.:D :beer: :mad: :confused: :eh?:
I made a code sample that should help you out, paste it in a project, with 1 form, 1button, 1 textbox, 1 listbox all using default names.
Private Sub Command1_Click()
For i = 0 To List1.ListCount - 1
If List1.Selected(i) = True Then
Text1.Text = List1.List(i)
End If
Next i
End Sub
Private Sub Form_Load()
List1.AddItem ("test1")
List1.AddItem ("test2")
End Sub
note: if you allow multiselects on the listbox, this code also works, but you need to make sure that you don't overwrite data. change the code in the IF -> END IF sturcture
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.