Replace squares with newlines

Posted on 2009-02-12
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

Question by:FMabey
    LVL 12

    Expert Comment

    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),"")
    LVL 12

    Accepted Solution

    If your textbox is multiline =true and you want the enter then

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

    Author Closing Comment

    Excellent. Thanks

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
    Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now