0

I am currently using this code to remove to much new lines from an explode string..

Me.rtb.Lines = Me.rtb.Text.Split(New Char() {ControlChars.Lf}, _
    StringSplitOptions.RemoveEmptyEntries)

I use RichTextBox. I split those string with

incoming = stringOfRtb.Split(ControlChars.CrLf.ToCharArray) ''vcrlf splitter

as a result, i get strings per line.. but sometimes, I think the first code removes not only the white spaces, but also the vbCrlf or the newlines that the module sends back. now the awful thing here is, it appears on random places so the strings that I put into textboxes shuffles and gets other arrays every time I receive the same data.

enter image description here

sometimes, its like this..

enter image description here

AdorableVB
  • 1,383
  • 1
  • 13
  • 44
  • `Me.rtb.Lines` is an array of the lines already - why are you trying to split it again? – OneFineDay Nov 08 '13 at 02:11
  • you see, the module sends back an explode string, and I need to put every bit of data in per textbox. so I need to split it. the first problem that I have encountered is that is sends its data with too much newlines in it in different places so I can't get a fix line of array that I need. can you still follow? so I put the first code so that every time I get data, it has fix lines, however, a new problem arose, now it somewhat removes some newlines that are not intended to. like this.. ip=192.168.1.1 mask=255.255.255.1 it appears like this.. ip=192.168.1.1mask=..... – AdorableVB Nov 08 '13 at 02:24
  • So what happens if you do: `Dim ipArray = rtb.Lines.ToArray()`? – OneFineDay Nov 08 '13 at 02:28
  • I'm wondering if replacing all the newlines with spaces, then splitting by space with removeemptyentries would fix it. A sample of the incoming data and exactly how you want it to look would help. – tinstaafl Nov 08 '13 at 02:31
  • it only added few more spaces Dona. I am thinking of that tinstaafl, replacing all "newlines" to an identical char so I could split it that way. what do you need? – AdorableVB Nov 08 '13 at 02:43
  • Check this out: http://stackoverflow.com/questions/7647716/how-to-remove-empty-lines-from-a-formatted-string – the_lotus Nov 08 '13 at 15:03

1 Answers1

0
While rtb.Text.contains("vbLf")
rtb.txt = rbt.txt.replace("vbLfvbLf","vbLF")
end while

this code should make double chars into one.

AdorableVB
  • 1,383
  • 1
  • 13
  • 44