VB.NET Tried all line break options, still cannot get exact result

I want to create a multi-line delimiter to split a text document.

The overall delimiter looks something like this.

\r\n is the actual carriage return and line feed, they are shown here as escape characters for visualization purposes.

Address\r\n
Line 1\r\n
Line 2\r\n
Line 3\r\n

To create this delimiter, I have to put together two strings.

  1. “Address”
  2. “Line 1\r\nLine2\r\nLine3\r\n”

How do I concatenate the two strings together with the \r\n in the middle? (only one line break)

I tried using Environment.NewLine but I printed this out in a message box, the concatenated result is a two line break.

Edit: I tried using vbCrLf but I get the same result as well

What I need is:
Address
Line1
Line2
Line3

What I currently get is:
Address

Line1
Line2
Line3

Did you not get any solution in you previous post?

Request you to create one post only for a topic which is not already there on the forum.

You can continue your discussion there only

Thanks,
Prankur

Nope, this problem is different. Previous post I was trying to split a string, now I want to concatenate instead. It seems like I tried all the options listed (vbNewLine, vbNewLine, vbCrLf, Environment.NewLine) but I can’t get the exact results. I keep getting double line break instead of single line break when I try to print the result in a message box.

Here you go again :slight_smile:
image

Ok, now what I want to do is detect the first instance of vbCrLf and delete it.

e.g.

“\r\n
Line1\r\n
Line2\r\n
Line3\r\n”

looks something like this, I have to clean it up by removing the first \r\n

How do I do this?

Can you try this?

lines.Substring(lines.IndexOf(Environment.NewLine)+1)