Results 1 to 2 of 2

Thread: An exciting question...

  1. #1

    Thread Starter
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425
    Say I have a text file containing data, which I read into several arrays, one for each "field"...I populate a list box with items in the first array. I also have several text boxes on the form. When an item in the list box is clicked, how do I put the items from the other arrays (with a corresponding element number) into the text boxes?

  2. #2
    ricmitch_uk
    Guest
    I've done this type of thing b4 I think, do you mean like this:
    Code:
    Public Sub Form1_Load()
    Dim i As Integer
    i = 0
    Open "data.dat" For Input As #1
    Do
    Input 1, strNames(i)
    Input 1, strAge(i)
    Input 1, strHobbies(i)
    i = i + 1
    Loop Until EOF(1)
    End sub
    
    Public Sub List1_Click()
    Dim intNumItems As Integer
    Dim intSelectedItem As Integer
    intNumItems = List1.CountItems - 1
    For intSelectedItem = 0 To intNumItems
    If List.Selected(intSelectedItem) = True Then Exit For
    Next intSelectedItem
    
    txtAge.Text = strAge(intSelectedItem)
    txtHobbies.Text = strAge(intSelectedItem)
    End Sub
    For this to work, the arrays need to be global and declared in a seperate module, and the sorted property of the list MUST be false. If you want the list sorted alphabetically then do that when you write the file in the first place.
    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width