How do I extract the first line in a listbox? I know that to take data out you use lstBox.Text, but how do I automatically select line 1 before doing this?
Printable View
How do I extract the first line in a listbox? I know that to take data out you use lstBox.Text, but how do I automatically select line 1 before doing this?
VB Code:
Private Sub Command1_Click() List1.ListIndex = 0 End Sub
This is very weird...because I tried that, and list1.listindex keeps on turning into -1 which is messing with the code I am trying to do :-)
Edit: Me doing my usual FUBAR stuff...t'was a bug elsewhere...the listindex is of course firing the list1_click which is doing stuff which ruins it all...easy to fix...thanks for the help :-)
Just a point. You may want to check that there is something in the ListBox first:
VB Code:
Option Explicit Private Sub Command1_Click() If List1.ListIndex > -1 Then List1.ListIndex = 0 End Sub
Yeah, I was doing that...the issue wasn't that, it was something to do with me using .removeitem afterwards in a sub which was messing with it or somethingQuote:
Originally Posted by Bruce Fox