Results 1 to 6 of 6

Thread: Read/Write 2 Lines

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    114

    Read/Write 2 Lines

    Hello all, i'd like to know howto read one line (define it to a variable), and then do the next with the string on the next line. thanks guys ^^

  2. #2

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    114

    Re: Read/Write 2 Lines

    sorry forgot to mention that ^^;
    text file

  4. #4

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    114

    Re: Read/Write 2 Lines

    not quite, what i meant is to have 2 variables, one for each line, and also howto write not only read thanks ^^

  6. #6
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Read/Write 2 Lines

    I showed one quick technic that could easily be accomodated to suit your need...
    Here is another:
    VB Code:
    1. Dim strText As String
    2. Dim arLines() As String
    3. Dim i As Integer
    4.  
    5. Open "c:\test.txt" For Input As #1
    6.     'read entire file
    7.     strText = Input(LOF(1), #1)
    8. Close #1
    9. 'split text on the carriage return
    10. arLines() = Split(strText, vbNewLine)
    11. 'loop through array
    12. For i = 0 To Ubound(arLines)
    13.     Debug.Print arLines(i)
    14. Next i

    To write to a file just open it for Output (to create a brand new or overwrite existing) OR for Append.

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