[RESOLVED] string.remove() help
Hey.
I am building an app that displays a log file from mirc onto my g15 display.
I want to remove the written timestamp infront the text, in the log file.
I do it this way:
vb.net Code:
Private Sub RefreshLCD()
Dim ts As String() = temp.Split(Chr(10))
For g As Integer = 1 To ts.Length - 1 Step 1
If ts(g).Contains("<") Then
ts(g) = ts(g).Remove(0, ts(g).IndexOf("<"))
End If
Next
End Sub
'Yes there's more code, but it's that part i'm talking about.
The problem is, it DOESN'T remove the timestamp. I've tried breakpointing it and it does find a < sign.
Here's the text that the array ts holds:
Code:
03[00:56] * jayb ([email protected]) has joined #test
02[00:58] * jayb ([email protected]) Quit (Signed off)
00[01:12] <Linkyyy> test
00[01:12] <Linkyyy> test
00[01:12] <Linkyyy> test
00[01:12] <Linkyyy> test
Session Close: Wed Jun 03 01:24:26 2009
If you need the whole code from RefreshLCD() then say so, and i'll post it.
Re: [RESOLVED] string.remove() help
well it looks to me that in the first way while you were removing the timestamp from ts(g) you were printing the one from ts(ts.Length - g), which is not the same one you just removed. For instance, on the first iteration, you would have removed the timestamp from index 1 but printed index N-1 which is last one in the array.
I think if changed ts(g) = ts(g).Remove.... to
Code:
if (ts(ts.Length - g).Contains("<")) Then
ts(ts.Length - g) = ts(ts.Length - g).Remove(0, ts(ts.Length - g).IndexOf("<"))
then that would have worked. What you were doing was removing the timestamp for a different index than you were printing. This would print everything from the middle index down incorrectly with the timestamp but from the first index to the middle index correctly.
Re: [RESOLVED] string.remove() help
oh.. Yes you're right. haha, thanks for letting me now. stupid mistake to make :)