Results 1 to 2 of 2

Thread: Open Text-file in textbox and listbox (VB3)

  1. #1

    Thread Starter
    Hyperactive Member Matt-D's Avatar
    Join Date
    Nov 1999
    Location
    Mettmann, Germany
    Posts
    305
    In my programm there's listbox (List1) and a text-box,
    which I can save in a Text-File. The first line of the
    textfile is the text form the textbox and the following
    lines are from the listbox. (Method from OneSource)

    -> How must I write the code, that the first line gets
    into a textbox and the rest into the listbox when I open
    the file ?


    For this programm I use VB 3.0 (but normally this isn't a
    problem)

    Thanks for some advice, Matt
    [hr]

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    Code:
    Dim bFilledTextBox as Boolean
    Dim sLine as String
    
    lstRestofFile.Clear
    
    Open "c:\filename.txt" For Input As #1
    
    Line Input #1, sLine
    
    Do While not Eof(1)
      If not bFilledTextBox Then
        txtFirstLine.Text = sLine
        bFilledTextBox = True
      Else
        lstRestofFile.Add sLine
      End if
      Line Input #1, sLine
    Loop
    
    Close(1)

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