Click to See Complete Forum and Search --> : RichText Box


AA.Keynia
December 2nd, 1998, 08:54 AM
How I can write in a RichTextBox using multiple font color?


Thanks,

AA.Keynia

Justin Decker
December 2nd, 1998, 10:34 PM
The SelColor property.

A. Karthikeyan
December 3rd, 1998, 12:43 AM
Hi,

If you want to change the color of the text in Rich Text Box, first select the text to be changed and use selcolor property. I have added a sample vb code.


Place a richtextbox and change the name property to rt.

Load a text file with word Start# and End#.

The following code will change the contents in between Start# and End# to red color.


Private Sub Form_Load()

startpos = 0

Do While Not flag

rt.SelLength = 0

startpos = rt.Find("START#", startpos)

If startpos = -1 Then flag = True

startpos = startpos + rt.SelLength

rt.SelLength = 0

endpos = rt.Find("END#", startpos)

If endpos = -1 Then flag = True

If Not flag Then

rt.SelStart = startpos

rt.SelLength = endpos - startpos

rt.SelColor = vbRed

End If

startpos = endpos

Loop

End Sub



I hope this code also will help you.


Bye


A. Karthikeyan