Results 1 to 2 of 2

Thread: Getting line by line from text file ??

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 1999
    Posts
    87
    How can I read Line by Line, from a text file ?

    ----TEXTFILE---
    C:\Windows
    C:\Windows\System
    C:\Windows\Start Menu
    ------END------

    And I want to get line by line and place it in a variable ?!
    How ?

    Thank you, Jerry.

    Homepage: http://fraxionsoftware.cjb.net
    ICQ: 40269591
    Mail: Contact Me

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    Use Line Input statement:
    Code:
    Dim FF As Integer: FF = FreeFile
    Dim strLine1 As String
    Dim strLine2 As String
    Dim strLine3 As String
        
    Open "C:\windows\desktop\myfile.txt" For Input As #FF
    Line Input #FF, strLine1
    Line Input #FF, strLine2
    Line Input #FF, strLine3
    Close #FF
    JUST AN UPDATE IF YOU DON'T KNOW THE LENGTH OF THE FILE:
    Code:
    Dim FF As Integer: FF = FreeFile
    Dim strLine() As String
    Dim Index As Integer
        
    ReDim Preserve strLine(Index)
        
    Open "C:\windows\desktop\myfile.txt" For Input As #FF
    Do While Not EOF(FF)
        Line Input #FF, strLine(Index)
        Index = Index + 1
        ReDim Preserve strLine(Index)
    Loop
    Close #FF
    [Edited by QWERTY on 07-18-2000 at 05:17 PM]

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