Results 1 to 3 of 3

Thread: [RESOLVED] [02/03] For Loop madness (array problem cont)

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2006
    Location
    NZ
    Posts
    178

    Resolved [RESOLVED] [02/03] For Loop madness (array problem cont)

    Thanks to jm who helped me the resizing array but for some reason I cannot get all the data listed in a listbox.
    Now resolved~! feel so silly
    I have a data file "Phonelist" with 3 lists to which can utilised as the actual directories after user selects (& if not exist needs to be created). My problem is that the For Loop only lists the last item (of 3) in the listbox!!!
    BTW you will see that I have been playing around trying to get it to work!

    VB Code:
    1. Sub DisplayDir(ByVal fn As String, ByVal path As String)
    2.     Dim sr As StreamReader
    3.     Dim sw As StreamWriter
    4.     Dim temp() As String
    5.     Dim prompt, read As String
    6.     Dim counter, i, j As Integer
    7.     fn = "PHONELISTS.TXT" 'File with phone directories
    8.     sr = File.OpenText(f & fn)
    9.     counter = 0 'Counts number of directories listed
    10.     Do While (sr.Peek <> -1)
    11.       counter += 1
    12.       sr.ReadLine()
    13.     Loop
    14.     ReDim temp(counter)
    15.     sr.Close()
    16.     'i = counter
    17.  
    18.     'Reads file in temp array
    19.     sr = File.OpenText(f & fn)
    20.     :wave:  Do While (sr.Peek <> -1) '[B]I forgot to do a for/next loop[/B]
    21.       temp(counter) = sr.ReadLine
    22.     Loop
    23.     'ReDim temp(i)
    24.     sr.Close()
    25.    [B] For j = 1 To counter
    26.       :confused:  lstOutput.Items.Add(temp(counter))
    27.     Next[/B]
    28.   End Sub
    Last edited by lionelnz; May 10th, 2006 at 07:02 PM. Reason: Resolved my own problem

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