Write in a text file without vbCrLf vb6

Posted on 2009-04-13
Last Modified: 2012-05-06
   I need to write in a text file in Visual Basic 6 some text lines but without the vbCrLf automatically inserted at the end of the line. If i use the following code:
   Open App.Path & "\TextFile.txt" For Output As #1
        Print #1, "Some text"
    Close #1

  this automatically inserts me an vbCrLf (Enter key) at the end of every line. I need to be able to choose if i want to insert Chr(13) or Chr(10) or both in a construction like this:
        Print #1, "Some text" & Chr(13)

    How can i do this?

 Thank you!
Question by:Cristi_E
  • 2
  • 2
LVL 59

Expert Comment

by:Chris Bottomley
ID: 24129920
Hello Cristi_E,

I think write supports this but afaik appends quote marks to strings - don't know if this is a problem of itself for you?


Author Comment

ID: 24129977
I dont really understand this part: "but afaik appends quote marks to strings ". Please can you be a little more explicit?
    Thank you!
LVL 59

Expert Comment

by:Chris Bottomley
ID: 24130260
afaik - as far as I know

Print #1, "Some text"
results in:
Some Text
with the CR LF being written to stream #1

Write #1, "Some text"
results in:
"Some Text"
 being written to stream #1 ... but no CR LF


LVL 76

Accepted Solution

GrahamSkan earned 500 total points
ID: 24131122
Put a semi-colon after the text.
Dim f As Integer

f = FreeFile

Open "C:\NoVbCr.txt" For Output As #f

    Print #f, "Text1" & vbCr;

    Print #f, "Text2" & vbCr;

Close #f

Open in new window


Author Closing Comment

ID: 31569503
Thank you verry much!

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now