Okay, how do I choose sertain text to change color, or to bold or italics?
And also, someone gave me code a while ago to put pictures into richtextboxs but I lost the code, can someone give it to me again. Thanks guys.
Printable View
Okay, how do I choose sertain text to change color, or to bold or italics?
And also, someone gave me code a while ago to put pictures into richtextboxs but I lost the code, can someone give it to me again. Thanks guys.
You can modify selected text like:
Or you can add ie. red text like this:Code:Text1.SelColor = 255
Text1.SelBold = 1
...
Everything clear? ;)Code:Text1.SelColor = 255
Text1.SelText = "Red Test"
Text1.SelColor = RGB(0, 0, 255)
Text1.SelText = "Blue Test"
To Put Picture's in a RichTextBox, you can just copy the picture, and Paste it in. (To get the Edit menu to appear when you Right-Click, set the AutoVerbMenu property to True.
Use the SelBold, SelItalic, SelUnderline and SelStrikeThru properties to change the Selected text to any of the 4 styles.
Use SelColor to change to a different Colour.Code:RichTextBox1.SelBold = Not RichTextBox1.SelBold
RichTextBox1.SelItalic = Not RichTextBox1.SelItalic
RichTextBox1.SelUnderline = Not RichTextBox1.SelUnderline
RichTextBox1.SelStrikeThru = Not RichTextBox1.SelStrikeThru
Code:'Changes to Blue colour
RichTextBox1.SelColor = vbBlue
Or you can change a certain portion of the text a different color and leave the rest black or any other color.
Code:Private Sub Form_Load ()
With RichTextBox1
.Text = "Welcome to the RichTextBox Sample Source Code!"
.SelStart = 0
.SelLength = Len(.Text)
.SelFontName = "Arial"
.SelFontSize = 10
.SelAlignment = rtfCenter
.SelStart = InStr(.Text, "RichTextBox") - 1
.SelLength = Len("RichTextBox")
.SelFontName = "Courier New"
.SelColor = vbBlue
.SelStart = InStr(.Text, "Sample Source Code") - 1
.SelLength = 4
.SelFontName = "Courier New"
.SelUnderline = True
.SelStart = .SelStart + 1
.SelLength = 1
.SelColor = vbRed
.SelStart = .SelStart + 1
.SelLength = 1
.SelColor = vbBlue
.SelStart = .SelStart + 1
.SelLength = 1
.SelColor = vbGreen
.SelStart = 0
.SelLength = 0
End With
End Sub
Thanks guys. Just what I was looking for :)
What about subscript and superscript?
Thanks,
Roger