the listbox gives the same info for all items.. (1 Viewer)

E

EYALHZ

Guest
I have this code:
Code:
        'Dim i As String = ListBox1.Items(4)
        'Select Case i
        '   Case 1
        Dim lines As String() = File.ReadAllLines(FileName, FileEncoding)
        Dim Line As String = lines(Int(Rnd() * (UBound(lines) + 1)))
        Dim Pos As Long = Line.IndexOf(" ")
        TextBox1.Text = Line.Substring(0, Pos)
        TextBox2.Text = Line.Substring(Pos + 1, Line.Length - Pos - 1)
        '  Case Else
        'MessageBox.Show("no item selected", "NO DATA", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        'End Select
it is in a listbox ,it supposed to take a text file from a directory (this is with form load) but when I click on one item in the listbox it put on the to textboxes the information but when I click on another item in the list box it still gives the same text file information,
How could I make a case select for each item in the listbox which will take those five lines(in that code) and will enter its information?!!!

please help me with this , if something is not clear I'll explain my self better.
 

Adeptus

What's this button do?
Local time
Today, 15:28
Joined
Aug 2, 2006
Messages
300
So, that code is in form load? and it works the first time?
Try putting it in listbox onclick (and maybe keypress as well, to handle cursor up/down)
 

Users who are viewing this thread

Top Bottom