I am using the following code, to import a few text files into a richtextbox, then it remove the lines that are the header lines of each file except for the first line. But when it finishes I end up with a couple of spaces between the lines like so. I have attached to code snippet. How can I remove the blanks or for that matter get never create them when removing header lines. Thanks
997,1885,1571,DDA,12/02/2008 16:50,12/02/2008 16:53,9845264556,5381-9631,Theresea LaBounty,917,,8,69.09,,070518898 019,,103104900,,,,,,d103104900d0070518898 019c 997,1885,1572,DDA,12/02/2008 17:19,12/02/2008 17:21,9845264556,5381-9631,Theresea LaBounty,918,,1,300,,070848717 019,,103104900,,,,,,d103104900d0070848717 019c 997,1885,1572,DDA,12/02/2008 17:19,12/02/2008 17:21,9845264556,5381-9631,Theresea LaBounty,918,,2,300,,070848716 019,,103104900,,,,,,d103104900d0070848716 019c
997,1927,1454,DDA,12/01/2008 8:07,12/01/2008 8:16,9848974748,5381-9631,sheila gayheart,1352,,1,272.5,195,117720896,,41000124,,,,,,d041000124d 117720896c 0!95 997,1927,1454,DDA,12/01/2008 8:07,12/01/2008 8:16,9848974748,5381-9631,sheila gayheart,1352,,2,388,686,4829326,,44101305,,,,,,d044101305d 4829326c 0686 997,1927,1454,DDA,12/01/2008 8:07,12/01/2008 8:16,9848974748,5381-9631,sheila gayheart,1352,,3,470,1945,10230048,,244180689,,,,,,d244180689d 10230048c 1945 997,1927,1454,DDA,12/01/2008 8:07,12/01/2008 8:16,9848974748,5381-9631,sheila gayheart,1352,,4,605,,3874192,,44101305,,,,,,d044101305d1602 c3874192c
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
|
For i = 0 To chkListBox1.CheckedItems.Count - 1
sSource = lblFolder.Text
sName = lblFolder.Text + "\" + chkListBox1.CheckedItems.Item(i).ToString
rtTextFiles.AppendText(IO.File.ReadAllText(sName) & Environment.NewLine)
'rtTextFiles.Lines(0).Remove(0, 255)
rtTextFiles.Lines(0) = rtTextFiles.Lines(0).Remove(0, 262)
Next i
' Now and try to get rid of lines we dont need
Dim lines() As String = rtTextFiles.Lines
For l = 1 To lines.Count - 1
If lines(l).StartsWith("Customer Number") Then
lines(l) = lines(l).Remove(0, rtTextFiles.Lines(l).Length)
Else
End If
Next l
rtTextFiles.Lines = lines
' now save the file
rtTextFiles.SaveFile("c:\achtest.csv", RichTextBoxStreamType.PlainText)
|
|