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

Replace squares with newlines

Medium Priority
220 Views
Last Modified: 2012-05-06
Hi all,

I've already posted a similar question and thought I cracked it so closed it out. However, I am having a few issues.

If you take the following sentence, taking not of the line spacings:

Once upon a time

In a Land, far far away

There lived a hobbit

This sentence would actually look like this in the SQL Server field, and more importantly in my multiline textbox in a Visual Studio textbox:

Once upon a time [2 little squares] In a Land, far far away [2 little squares] There lived a hobbit.

How do I remove these squares and re-format into the appropriate fashion?

I was using the attached code. I put this under the cell change of a datagridview, however, what I found was that it changed the value in the textbox everytime I moved cell, increasing the number of little squares!

Any ideas anyone?
TextBox1.Text = Replace(TextBox1.Text, Chr(10), vbNewLine)

Open in new window

Comment
Watch Question

DimitrisSenior Solution Architect

Commented:
the little squares are actually the ENTER (chr(13) + chr(10)
If you want to remove the enter and lose the new line formatting then use this

         

TextBox1.Text = Replace(Replace(TextBox1.Text, Chr(13), ""),Chr(10),"")
Senior Solution Architect
Commented:
If your textbox is multiline =true and you want the enter then

TextBox1.Text =  Replace(Replace(TextBox1.Text, Chr(13), ""),Chr(10),Environment.NewLine)

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

Ask the Experts

Author

Commented:
Excellent. Thanks
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.