PDA

Click to See Complete Forum and Search --> : RTF Colors


DiGiTaIErRoR
Nov 5th, 1999, 01:46 PM
Want to be able to assign certain words certain colors without having to select it i.e.
these commands
selstart
sellength
i just need to to change automatically like the VB editor

------------------
DiGiTaIErRoR

Yonatan
Nov 5th, 1999, 06:03 PM
Try this: (It does use selection, but it does not look like it is... Try it)

Dim OldSelStart As Long
RichTextBox1.TextRTF = "Hello World" ' Clear formatting and change text to Hello World
OldSelStart = RichTextBox1.SelStart ' Remember old SelStart
' Color the Hello:
RichTextBox1.SelStart = InStr(RichTextBox1.Text, "Hello") - 1
RichTextBox1.SelLength = Len("Hello")
RichTextBox1.SelColor = vbRed
' Color the World:
RichTextBox1.SelStart = InStr(RichTextBox1.Text, "World") - 1
RichTextBox1.SelLength = Len("World")
RichTextBox1.SelColor = vbBlue
' Clear selection:
RichTextBox1.SelStart = OldSelStart

------------------
Yonatan
Teenage Programmer
E-Mail: RZvika@netvision.net.il
ICQ: 19552879 (http://www.icq.com/19552879)