Hi again. I'm in a bit of trouble. The project I'm working on needs the use of listboxes, but I haven't the slightest idea how to use them. Could anyone give me a quick overview?
--
VB6 Professional
Printable View
Hi again. I'm in a bit of trouble. The project I'm working on needs the use of listboxes, but I haven't the slightest idea how to use them. Could anyone give me a quick overview?
--
VB6 Professional
Okay, here are the most usable functions of a listbox, to try this project, do the following:
- Make a new project
- Add a listbox-control
- Add three command-buttons
- Add this code:
Hitting the first button will ask you for any text which will be added as a row in the listbox. The second button will show you what's selected, if empty or if none selected it doesn't do anything. Third button will clear the listbox.Code:Private Sub Command1_Click()
List1.AddItem InputBox("Type something", "New list item", "hello world")
End Sub
Private Sub Command2_Click()
For x = 0 To List1.ListCount - 1
If List1.ListCount = 0 Then Exit For
If List1.Selected(x) Then
MsgBox "The data: " & List1.List(x) & " is selected."
Exit For
End If
Next x
End Sub
Private Sub Command3_Click()
List1.Clear
End Sub
This should get your running... :)
By the way, what you need to do with the ListBox Control? The ListBox control only can list all the Item that you've added into thier list, either at Design Time or Runtime.