|
-
Mar 3rd, 2004, 07:55 PM
#41
Thread Starter
Fanatic Member
I just got it working partially. I got an idea though. Is there any way to get the number of elements in an array?
Here's what happens:
First time, the green system message appears.
Second time, the black miscellaneous message appears.
Third time, the second green system message appears, and all text in the textbox turns green, including the *supposedly* black misc message.
Last edited by hothead; Mar 3rd, 2004 at 08:09 PM.
-
Mar 3rd, 2004, 08:08 PM
#42
Well, how about you post the code you are using again. It sounds like there have been some changes. Maybe we can get this resolved. Also explain why my code won't work.
-
Mar 3rd, 2004, 08:13 PM
#43
Thread Starter
Fanatic Member
I did make some changes to get it to work. Here's the way it looks:
VB Code:
Private Function ColorServerMessageLines()
Dim strArray() As String
strArray = Split(rtbServerMessages.Text, vbNewLine)
rtbServerMessages.SelStart = 0
For i = 0 To UBound(strArray)
rtbServerMessages.SelLength = Len(strArray(i)) + 2
If Left$(strArray(i), 6) = "SYSTEM" Then
rtbServerMessages.SelColor = DarkGreen
ElseIf Left$(strArray(i), 5) = "ERROR" Then
rtbServerMessages.SelColor = DarkRed
Else
rtbServerMessages.SelColor = vbBlack
End If
rtbServerMessages.SelStart = rtbServerMessages.SelStart + rtbServerMessages.SelLength
Next i
End Function
However, it only works the first couple times the code is run through. If I get something like this:
SYSTEM: Test
Test
SYSTEM: Test
the whole thing will turn green again. However, it'll work with something like this:
SYSTEM: Test
Test
Last edited by hothead; Mar 3rd, 2004 at 08:30 PM.
-
Mar 3rd, 2004, 08:32 PM
#44
Is the RTB changing at all while the coloring process is executing. What you describe seems impossible? I have tested a bunch of different ways and cannot duplicate your problem.
Can you show the code that adds the text to the RTB?
-
Mar 3rd, 2004, 08:44 PM
#45
Thread Starter
Fanatic Member
EDIT: I have already found the problem, it was a missing function call. It works completely now. Thanks a lot!
Last edited by hothead; Mar 3rd, 2004 at 08:50 PM.
-
Mar 3rd, 2004, 08:49 PM
#46
Originally posted by hothead
It goes through the loop twice for some reason, even though only one line is in the textbox
And........... a CarriageReturn (that you loaded in the Form Load Event)!
Hence the Array has two elements (0) being the first word, and (1) containing ""
Bruce.
-
Mar 3rd, 2004, 11:53 PM
#47
Frenzied Member
might i also suggest trimming any VBCrLf's (newline) from the end?
something like
VB Code:
Do Until Right(rtbServerMessages.Text, 2) <> vbCrLf
rtbServerMessages.Text = Left(rtbServerMessages.Text, Len(rtbServerMessages.Text) - 2)
Loop
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|