Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Replace squares with newlines

Posted on 2009-02-12
3
Medium Priority
?
212 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

0
Comment
Question by:FMabey
  • 2
3 Comments
 
LVL 12

Expert Comment

by:Dimitris
ID: 23620805
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
 
LVL 12

Accepted Solution

by:
Dimitris earned 2000 total points
ID: 23620823
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
 
LVL 3

Author Closing Comment

by:FMabey
ID: 31545991
Excellent. Thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question