ok here what i want to do like if there a word in the rtf Called Port I want the word port to be Blue and other words can someone in here please help me with this?
Printable View
ok here what i want to do like if there a word in the rtf Called Port I want the word port to be Blue and other words can someone in here please help me with this?
i have already answered this question, try searching next time :)
anyway, here it is for you
Code:RichTextBox1.Text = "Port: LPT1" 'Whatever the text is
RichTextBox1.SelStart = 0 'Where the other text before port ends
RichTextBox1.SelLength = 4 'the length of "Port"
RichTextBox1.SelColor = vbBlue 'Set the color of selected text
RichTextBox1.SelStart = Len(RichTextBox1.Text) 'Goto end of text box
------------------
david
Teenage Programmer
hey what do i use this code in it not working in the change code thing
RichTextBox1.Text = "Port: LPT1" 'Whatever the text is
Code:RichTextBox1.SelStart = 0 'Where the other text before port ends
RichTextBox1.SelLength = 4 'the length of "Port"
RichTextBox1.SelColor = vbBlue 'Set the color of selected text
RichTextBox1.SelStart = Len(RichTextBox1.Text) 'Goto end of text box
You can use this function I wrote:
Then call this sub routine like this:Code:Public Sub ColorWords(pRich As RichTextBox, pWord As String, pColor As OLE_COLOR)
Dim iPos As Integer
With pRich
iPos = InStr(iPos + 1, .Text, pWord, vbTextCompare)
Do While iPos <> 0
.SelStart = iPos - 1
.SelLength = Len(pWord)
.SelColor = pColor
iPos = InStr(iPos + 1, .Text, pWord, vbTextCompare)
Loop
End With
End Sub
ColorWords RichTextBox1, "Port", vbBlue
------------------
Serge
Senior Programmer Analyst
[email protected]
[email protected]
ICQ#: 51055819
Thanx Man That Otehr GuyDid Not Help Me With Crap You Help Alot It was Just What I Was Looking For