-
direct me somewhere
can anyone tell me or link me to what i should be reading up on when it comes to adding and removing items on a list from a listbox. like have a textfield where i type something, click a button. it's added to the list. and beside the add button, it removes what i have selected in the list. the listbox will also be loaded from a .txt document if that means anything.
thanks in advance.
-
Re: direct me somewhere
it is probably
Code:
list1.removeitem list1.listindex
fixed
-
Re: direct me somewhere
Use this
Code:
'~~> Add Item
Private Sub Command1_Click()
List1.AddItem Text1.Text
End Sub
'~~> Remove Selected Item
Private Sub Command2_Click()
List1.RemoveItem (List1.ListIndex)
End Sub
-
Re: direct me somewhere
Avoid falling into this odd habit though:
Code:
Private Sub Command2_Click()
List1.RemoveItem (List1.ListIndex)
End Sub
Those parentheses are incorrect, and can have nasty unexpected side effects if you don't understand what your use of them is asking the compiler to do. They are not innocuous, though you might get away with it 80% of the time.
This is a sort of "creeping crud" that happens when people use The Great Pretender (VB.Net) for a while, where Anders and Friends decided to warp decades-old Microsoft Basic syntax.
What you want here is:
Code:
Private Sub Command2_Click()
List1.RemoveItem List1.ListIndex
End Sub
-
Re: direct me somewhere
Reading from the .txt document depends on how it is written inside... Is it one entry for each line or is the entries seperates with a coma ","