[Last Call] Learn how to a build a cloud-first strategyRegister Now


Saving String Data that may include a carriage return

Posted on 2011-04-20
Medium Priority
Last Modified: 2013-12-25
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
Question by:BigOldDog
LVL 86

Accepted Solution

Mike Tomlinson earned 500 total points
ID: 35432584
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.
LVL 16

Expert Comment

ID: 35433268
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.

Author Closing Comment

ID: 35433281
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.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

831 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