To make selected text bold, underlined, italic or strikethrough
you can use the following code:
| Statement | Action |
| RichTextBox1.SelBold = True | Makes the selected text Bold |
| RichTextBox1.SelItalic = True | Makes the selected text Italic |
| RichTextBox1.SelUnderline = True | Makes the selected text Underlined |
| RichTextBox1.SelStrikeThru = True | Makes the selected text Strikethrough |
To change the alignment, simply use this syntax:
RichTextBox1.SelAlignment = Alignment
Where alignment is one of the following constants:
| Constant | Alignment |
| vbRight | Right |
| vbLeft | Left |
| vbCenter | Centre |
So, the following code will set make the selected text underlined, and aligned to the right.
RichTextBox1.SelAlignment = vbRight
RichTextBox1.SelUnderline = True
If you want to know how to make a toolbar that shows the current underlined/italic/etc state, click here.
Comments