|
-
Jan 29th, 2001, 08:55 PM
#1
Code:
Private Sub MakeColored()
For x = 1 To Len(rtfbox.Text)
If Mid(rtfbox.Text, x, Len("SELECT")) = "SELECT" Then
rtfbox.SelStart = x - 1
rtfbox.SelLength = Len("SELECT")
rtfbox.SelColor = vbBlue
rtfbox.SelLength = 0
rtfbox.SelColor = vbBlack
x = (x - 1) + Len("SELECT")
Else
rtfbox.SelColor = vbBlack
End If
Next x
rtfbox.SelStart = Len(rtfbox.Text)
End Sub
I havve this code to look for the word "SELECT" in a RichTextBox, and if found, color it blue. This works the first time, but if I run the code again, it colors evrything blue! Who can tell me why?
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jan 29th, 2001, 09:02 PM
#2
_______
<?>
It doesn't for me. Works fine..even if I click it 10 times the only work blue is Select
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jan 29th, 2001, 09:04 PM
#3
here's the thing, It does that for me too, but then I go to the next line in the box, add some more text, and run it again, and that's where it screws up...I don't know...
EDIT
I have it on the KeyPress event and it runs when the ENTER key is pressed...
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jan 29th, 2001, 10:14 PM
#4
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jan 29th, 2001, 10:20 PM
#5
Reset all the text to black before colouring the text again. Ok, so it's a brute force approach, but it should work.
- gaffa
-
Jan 29th, 2001, 10:21 PM
#6
Alright, I'll try that...
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Jan 29th, 2001, 10:49 PM
#7
cool, that worked, thanks gaffa...
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
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
|