Rondell Wayne Ivey
Rondell Wayne Ivey

Reputation: 11

Replace a comma with new line in RTF

I have a Richtextbox that contains text.

For example, it contains Example1,Example2,Example3.

I'm wanting it to replace the commas with a newlines, so it should look like this:

Example1
Example2
Example3

but I don't know how to do this.

I've googled and searched around for this but nothing seems to work.

Upvotes: 0

Views: 846

Answers (2)

Andrew Morton
Andrew Morton

Reputation: 25013

In RTF, the code for the end of a paragraph is \par followed by a delimiter, which may as well be a space for this purpose. So you can use:

RTB1.Rtf = RTB1.Rtf.Replace(",", "\par ")

Upvotes: 2

laancelot
laancelot

Reputation: 3207

You can use Replace(oldStr, newStr) like this:

myRichTextBox.Text = myRichTextBox.Text.Replace(",", vbNewLine)

Have fun.

Upvotes: 0

Related Questions