[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Carriage Return in VB.NET multiline textbox

Posted on 2009-02-11
8
Medium Priority
?
2,612 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
0
Comment
Question by:FMabey
  • 4
  • 3
7 Comments
 
LVL 4

Accepted Solution

by:
512Thz earned 1500 total points
ID: 23611339
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))
0
 
LVL 4

Expert Comment

by:512Thz
ID: 23611365
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)
0
 
LVL 3

Author Comment

by:FMabey
ID: 23611451
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???
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Author Comment

by:FMabey
ID: 23611527
I've got it!!!

TextBox1.Text = Replace(TextBox1.Text, Chr(10), vbNewLine)
0
 
LVL 4

Expert Comment

by:512Thz
ID: 23615968
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!
0
 
LVL 4

Expert Comment

by:512Thz
ID: 23615979
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
0
 
LVL 3

Author Comment

by:FMabey
ID: 23620044
Fair comment 512Thz. To be honest I was going to award you the points but closed the question and then realised  couldn't!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Screencast - Getting to Know the Pipeline
Suggested Courses

873 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