Saving String Data that may include a carriage return

I use the following code to write data to a file opened for Append
       Write #F, SerialNo; fn; fs, fb; fi; fu; ft; tc; tb; n; TDNtext; SaveFlag
The variable TDNtext is a string read from a TextBox control (Multiline = True).
My problem is that if the user uses a carriage return in the text he is entering this seems to function as an end / new record when the data is written to file.
I can see one way around this by use of a Rich Text Box in place of a normal text box, but I want to avoid that if at all possible
BigOldDogAsked:
Who is Participating?
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
One solution is to replace vbCrLf with something else that won't appear in the TextBox.  You could use an unlikely sequence like "|*|*|vbCrLf|*|*|.  Just change it back after you read it from the file.
http://msdn.microsoft.com/en-us/library/aa241892(VS.60).aspx
0
 
HooKooDooKuCommented:
I don't understand how a Rich Text Box is going to help you.  If the Rich Text Box is Multiline, you're still going to get a CrLf pair between lines.

What are your constraints?  Do your records need to account for line breaks that were in the original text box?  If so, then I would say that "Replace vbCrLf with something else" is not "one solution", but the ONLY solution since a "Record" in your data file appears to be deliniated by new lines.
0
 
BigOldDogAuthor Commented:
Works fine in VB6 but I do not think that this command exists in VB5. I am just migrating from 5 to 6 so that's not a problem.
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.