how do i know if selected text, i.e. rtf.seltext, contains two or more font types such as two different font names or two different font size?
Printable View
how do i know if selected text, i.e. rtf.seltext, contains two or more font types such as two different font names or two different font size?
I could be wrong on this but I thought that the rtf just takes the last font selection and that is the selection for the whole box.
ie> everything is bold and NewRoman 12
Code:
Private Sub Form_Load()
With RichTextBox1
.Text = "line one" & vbCrLf
.Font = "courier"
.Font.Size = "14"
.Text = .Text & "line two" & vbCrLf
.Font = "New Roman"
.Font.Size = 12
.Font.Bold = True
.Text = .Text & "line three"
End With
End Sub
This will detect the text's font in the RichTextBox:
If you want to extract the contents of the RichTextBox:Code:Private Sub Command1_Click()
If RichTextBox1.SelText <> "" Then
Msgbox RichTextBox.SelFontName
End If
End Sub
Code:Private Sub Command1_Click()
If RichTextBox1.SelText <> "" Then
Msgbox RichTextBox.SelRTF
End If
End Sub
I wasn't really asking for what you guys had in mind... but it's ok, I figured how to do it by errorhandling.. thans anywayz