What you need
QUOTE
| Name
ListBox | List1
TextBox | Text1
TextBox | Text2
Command Button | Command1
Command Button | Command2
Command Button | Command3
Command Button | Command4
-----------
Actual Code:
---
'Start Code
Private Sub Command1_Click()
'This will check if there is anything in Text1 and stop if there isn't, but if there is it will add the text in Text1 to the listbox
If Text1.Text = vbNullString Then
MsgBox "Please enter a value for the string to add!", vbInformation + vbOKOnly, "Error"
Exit Sub
End If
List1.AddItem Text1.Text
End Sub
Private Sub Command2_Click()
'This will remove the item in the listbox, if it is at an index
If List1.ListIndex < 0 Then
Exit Sub
End If
List1.RemoveItem List1.ListIndex
End Sub
Private Sub Command3_Click()
'This will navigate to the item
Dim i As Integer
For i = 0 To List1.ListCount - 1
If Text2.Text = List1.List(i) Then
List1.ListIndex = i
End If
Next
End Sub
Private Sub Command4_Click()
'This will remove the found item
Dim i As Integer
For i = 0 To List1.ListCount - 1
If Text2.Text = List1.List(i) Then
List1.RemoveItem i
End If
Next
End Sub
Private Sub Text1_Click()
'Clears the textbox for the user's conveinance
Text1.Text = vbNullString
End Sub
Private Sub Text2_Click()
Text2.Text = vbNullString
'Clears the textbox for the user's conveinance
End Sub
'End Code
'----------------------
ListBox | List1
TextBox | Text1
TextBox | Text2
Command Button | Command1
Command Button | Command2
Command Button | Command3
Command Button | Command4
-----------
Actual Code:
---
'Start Code
Private Sub Command1_Click()
'This will check if there is anything in Text1 and stop if there isn't, but if there is it will add the text in Text1 to the listbox
If Text1.Text = vbNullString Then
MsgBox "Please enter a value for the string to add!", vbInformation + vbOKOnly, "Error"
Exit Sub
End If
List1.AddItem Text1.Text
End Sub
Private Sub Command2_Click()
'This will remove the item in the listbox, if it is at an index
If List1.ListIndex < 0 Then
Exit Sub
End If
List1.RemoveItem List1.ListIndex
End Sub
Private Sub Command3_Click()
'This will navigate to the item
Dim i As Integer
For i = 0 To List1.ListCount - 1
If Text2.Text = List1.List(i) Then
List1.ListIndex = i
End If
Next
End Sub
Private Sub Command4_Click()
'This will remove the found item
Dim i As Integer
For i = 0 To List1.ListCount - 1
If Text2.Text = List1.List(i) Then
List1.RemoveItem i
End If
Next
End Sub
Private Sub Text1_Click()
'Clears the textbox for the user's conveinance
Text1.Text = vbNullString
End Sub
Private Sub Text2_Click()
Text2.Text = vbNullString
'Clears the textbox for the user's conveinance
End Sub
'End Code
'----------------------
The above code shows you how to loop through a listbox, to find/remove an item, and to check if a textbox has anything in it.
OMG I AM SORRY! THIS IS THE WRONG FORUM!! PLEASE MOVE THIS

