Hi there folks,
I'm somewhat of a major beginner in Visual Basic. I'm using VB 2005 Express and am having some basic trouble with RTB formatting.
I have geared it up so that a user can format text in a Rich Text Box with either bold, italics or underline. However when one option is selected it overrides the previous command, so for instance I can't get it to have Bold and Italics at the same time.
Here is my code:
CODE
If Not RichTextBox1.SelectionFont Is Nothing Then
Dim currentFont As System.Drawing.Font = RichTextBox1.SelectionFont
Dim newFontStyle As System.Drawing.FontStyle
If RichTextBox1.SelectionFont.Bold = True Then
newFontStyle = FontStyle.Regular
Else
newFontStyle = FontStyle.Bold
End If
RichTextBox1.SelectionFont = New Font(currentFont.FontFamily, currentFont.Size, newFontStyle)
End If
Is there any obvious problem with my coding? How can I fix the problem?
Many thanks,
Kev