Carriage Return in VB.NET multiline textbox

Hi all,

I have imported a text file into SQL Server 2000. This text file included a field that had little squares in it which showed where the user had pressed return/enter and gone down a line. In some places there are two little squares where the user has gone down 2 lines and so on...

When I open this up in a multiline text box on a windows form I see the little squares. How do I replace these which actual new lines?

Thanks
LVL 3
FMabeyAsked:
Who is Participating?
 
512ThzCommented:
I suspect that you have only the "line feed" (character &h10) and that is why you get one square.

You could use the ".Split" method to break the lines followed by the ".Join" method to bring it back but with "Carriage Return" AND "Line feed" this time

 Dim temp() As String = theFile.Split(Char(&h10))
0
 
512ThzCommented:
To ckeck if it is a one character delimiter (Unix like eol) open the file with WordPad (not Notepad)

Do a dummy modification (inseet a line then delete it)

Save the file

Try with that file. If it works, you have a file with a single line feed instead of the format commonly used on Windows (carriage return + Line feed)
0
 
FMabeyAuthor Commented:
Thanks for your answers.

I've been trying the following which gets rid of the little squares:

TextBox1.Text = Replace(TextBox1.Text, Chr(10), vbNullString)

However, how do I actually replace the Chr(10) with a new line???
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
FMabeyAuthor Commented:
I've got it!!!

TextBox1.Text = Replace(TextBox1.Text, Chr(10), vbNewLine)
0
 
512ThzCommented:
I found the reason why you had square box instead of new lines. You choosed an alternate method to replace the Chr(10) by the Chr(13) & Chr(10) However I pointed you to the root cause and gave you a workarond. I think that closing the question is unfair. You've been helped please give credit!
0
 
512ThzCommented:
I found the reason why you had square box instead of new lines. You choosed an alternate method to replace the Chr(10) by the Chr(13) & Chr(10) However I pointed you to the root cause and gave you a workarond. I think that closing the question is unfair
0
 
FMabeyAuthor Commented:
Fair comment 512Thz. To be honest I was going to award you the points but closed the question and then realised  couldn't!
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.