CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2000
    Posts
    4

    Carriage Returns/New Lines in file

    I am trying to write a file that will be read on a UNIX box. The following code always writes a CR/NL combo at the end of each line:

    dim i as integer
    i = freefile
    open "C:\TEXT.TXT" for output as i
    print #i, "Hello there, World"
    close #i

    I have tried the following code but end up getting byte counts at the beginning of the line:

    dim i as integer
    i = freefile
    Open "C:\text.txt" For Binary Access Write As #i
    Put #i, , "Hello there, World" & Chr(10)
    Close #i


    Can somebody please explain to me if this is possible or not?

    Thanks,
    Mark
    [email protected]


  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Carriage Returns/New Lines in file

    If what you are trying to do is eliminate the CRLF after each line replacing it with a NL try thie

    print #i, "Hello there, World"; vblf;


    Note the ; (semi-Colon) after the vbLF. This tells VB you are not finished with the current line and do not append a crlf after it. DO this for the entire file alwaays ending your print command with the ;

    John G

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

Featured