• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

Replace squares with newlines

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

0
FMabey
Asked:
FMabey
  • 2
1 Solution
 
DimitrisSenior Solution ArchitectCommented:
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),"")
0
 
DimitrisSenior Solution ArchitectCommented:
If your textbox is multiline =true and you want the enter then

TextBox1.Text =  Replace(Replace(TextBox1.Text, Chr(13), ""),Chr(10),Environment.NewLine)
0
 
FMabeyAuthor Commented:
Excellent. Thanks
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now