Results 1 to 2 of 2

Thread: umm

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Location
    Federal Way, WA, USA
    Posts
    13
    here is my code

    Code:
    Private Sub Command2_Click()
    
        Open "yob.dat" For Input As #1
        'Opens the file given by the user.
        
        Do Until EOF(1)
        'Does this loop until End Of File(EOF) for file number
            Line Input #1, Data
            'Read one line and puts it into the varible Data.
            picbox.Print Data
            'Adds the read line into Text1.
        Loop
        
        Close #1
        
    End Sub
    With the textbox It reads the data out of the file and puts it all in one line. I want it to put it in separate lines.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Your code is missing something:
    Code:
    Private Sub Command2_Click()
    
        Open "yob.dat" For Input As #1
        'Opens the file given by the user.    
        Do Until EOF(1)
        'Does this loop until End Of File(EOF) for file number
            Line Input #1, Data
            'Read one line and puts it into the varible Data.
            'Adds the read line into Text1.
            'It was missing this line:
            Text1.Text = Text1.Text & vbCrLf
        Loop
        Close #1
    End Sub
    Also, don't use 1 for FileNumber, because the FileNumber canbe taken (if you have more then 1 file opened), instead you can get the next available FileNumber by using FreeFile function.

    Code:
    Dim iFFN As Integer
    
    iFFN = FreeFile
    Open "C:\MyFile.txt" For Input as iFFN
    'Read the file
    Close #iFFN

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