Replacing Multiple vbNewlines
Hi, i'm trying to replace multiple vbnewline's as to only allow two vbnewline's in my textbox. I sort of have a idea how i could do it by counting each instance of vbnewline that appears in my string and then replacing them with only two vbnewline's. But the problem is how could i duplicate the vbnewline sub string using a integer value to match the number of instances found in the string, something simmilar to the string() function.
Re: Replacing Multiple vbNewlines
I'm struggling to work out what the data in your TextBox might look like, can you give and example of 'before'and 'after' please ?
Re: Replacing Multiple vbNewlines
text1.text = replace(text.text, vblf & vbcr, "")
will remove all empty lines in text box, except if there is empty line at the end
Re: Replacing Multiple vbNewlines
@Doogle The correct formatting of the data would look like this:
Code:
Description:
Description here
more info
more info
even more info
Incorrect would be something like this:
Code:
Description:
Description here
more info
more info
even more info
So basically i need to replace any new lines that are more than 2, with 2 new lines.
Re: Replacing Multiple vbNewlines
Keep looping until all triple vbNewLines are replaced with two vbNewLines.
vb Code:
Do While InStr(Text1.Text, vbNewLine & vbNewLine & vbNewLine) > 0
Text1.Text = Replace(Text1.Text, vbNewLine & vbNewLine & vbNewLine, vbNewLine & vbNewLine)
Loop