Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find "Return" character and Replace in String 2

Status
Not open for further replies.

kvang

Programmer
Oct 7, 2005
129
US
I have a VB.NET application that reads a text file to write to a database table. The text file may contain a "Return" character which my application does not recognize and causes the application to error out.

I read one line from the text file into a string and parse the string using .Substring(Index,Count) into several string variable. When I try to parse the line that contains the "Return" character, it would error out. How can I look for the "Return" character before parsing it into a variable?
 
Try searching your string for vbCr. Once found, replace it with the character of your choice. You may also have to look/replace vbLF and/or vbCrLf (carraige return/linefeed)
 
You should be able to do something like:

Code:
MyString = MyString.replace(controlchars.crlf," ")

Depending on what type of system the files came from, the return might be a CR or a CRLF.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top