We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Carriage Return in VB.NET multiline textbox

FMabey
FMabey asked
on
Medium Priority
2,770 Views
Last Modified: 2012-05-06
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
Comment
Watch Question

Commented:
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))

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
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)

Author

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???

Author

Commented:
I've got it!!!

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

Commented:
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!

Commented:
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

Author

Commented:
Fair comment 512Thz. To be honest I was going to award you the points but closed the question and then realised  couldn't!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.