Rich Text Box Controls

Colors, bullets & superscript

First there's coloring.  You set this by changing the SelColor to the color of your choice.  You can use any color (vbcolor, RGB, QBColors).

Object.SelColor = color

RichTextBox1.SelColor = vbGreen
'Now anything typed will be green

Now protecting.  Protecting disabled editing from the selected text

Object.SelProtected

RichTextBox1.SelProtected = True

Any text that was selected during this method is now protected.

Bullets are creating by setting the SelBullet property to true.  This creates bullets where new lines are put, and the line the cursor was just at.

Object.SelBullets = True

'RichTextBox displays:
'We are know for:
'Creating programs
RichTextBox.SelBullets = True
'RichTexBox now displays
'We are know for:
'·Creating programs

With the bullets you can indent them using BulletIndent

Object.BulletIndent = Integer

'Using the one before
'RichTextBox1 displays:
'We are know for:
'·Creating programs
RichTextBox1.BulletIndent = 200
'RichTextBox1 no displays:
'We are know for:
'·       Creating programs

Next is how to superscript or subscript. To make superscript or subscript you have to use the SelCharOffSet and SelFontSize at the same time.  The SelCharOffSet just changes the position of the text.  

Using the SelCharOffSet property:

Object.SelCharOffSet property

   To subscript, you just need to change the SelFontSize.  If you want to superscript, you must change the font size and the SelCharOffSet.
Hello
SubScript:

Dim VariableName As Integer
Integer = Object.SelFontSize
Object.SelFontSize = Integer / 3 * 2
'This makes the size 2/3 of the original

SuperScript:

Dim VariableName As Integer
Object.SelFontSize = Integer / 3 * 2
Object.SelCharOffSet = Temp * 5

That is how you can make a subscript or superscript font.  They covers most of the control on the rich textbox.

You might also like...

Comments

About the author

ZERO-COOL United States

I'm a 12 year old child who is interested in learning programming languages. My current two are Visual Basic and C++.

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Programs must be written for people to read, and only incidentally for machines to execute.”