Results 1 to 21 of 21

Thread: [RESOLVED] Write To File With Append Creates New Line when it shouldn't

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2010
    Location
    Gold Coast, Australia
    Posts
    43

    Resolved [RESOLVED] Write To File With Append Creates New Line when it shouldn't

    I have tried searching the forums for an answer but i could not find what i was looking for,

    I'm basically trying to Write to a text file using the Append instead of Output function so that it puts all of the text on the same line.

    However after 81 characters in the text document a new line is created and the remaining string that should have been on the first line starts on a new line.

    Things i have tried:
    • Taking off word wrap on notepad
    • Putting a ";" at the end of each line


    everything works fine, except depending on the length of account(i).ip and account(i).date the string will start a new line regardless of the code.

    Is this a fault of notepad? Or is it something to do with my code? If there is no solution i may have to try using a SQL server or something which is too overboard for my small project. Thanks heaps for anyone that has any ideas.


    Here is my code:

    Code:
    Public Sub write_data()
        Open App.Path & "\accounts.dat" For Append As #1
            For i = 0 To totalaccounts - 1
                Print #1, account(i).firstname & "¿";
                Print #1, account(i).surname & "¿";
                Print #1, account(i).username & "¿";
                Print #1, account(i).password & "¿";
                Print #1, account(i).email & "¿";
                Print #1, account(i).compUser & "¿";
                Print #1, account(i).compName & "¿";
                Print #1, account(i).ip & "¿";
                Print #1, account(i).date; vbCrLf
            Next i
        Close 1
    End Sub

    This is also the text that gets written to my output file (accounts.dat) as it appears in notepad:

    Code:
    john¿doe¿johnny¿password¿[email protected]¿John¿JOHN-PC¿10.0.0.1
    ¿8/03/2011
    as you can see the date is on a new line, but by using "Append" instead of "Output" and the ";" should keep it on the same line.. hmm
    Last edited by koushi; Mar 8th, 2011 at 08:45 AM. Reason: adding a code snippet

Tags for this Thread

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