Search code examples
vb.netrichtextboxlastindexof

How to insert new line(vbnewline) after specific word in richtextbox vb.net


How to insert new line(vbnewline) after specific word in richtextbox vb.net heres the ex.

ITEM # 1234 BLUE 100.00 ITEM # 3214 RED ITEM # 1235 GREEN 120.00 ITEM # 3514 ORANGE

The output should be

ITEM # 1234 BLUE 100.00
ITEM # 3214 RED 211.00
ITEM # 1235 GREEN 120.00
ITEM # 3514 ORANGE 543.00

Solution

  • How About...

    Dim Input as string= "ITEM # 1234 BLUE 100.00 ITEM # 3214 RED ITEM # 1235 GREEN 120.00 ITEM # 3514 ORANGE"
    Dim Output as string= Input.Replace("ITEM", Environment.Newline & "ITEM" & Environment.Newline)