Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Jul 24, 1998

Use Subscripts and Superscripts

You can use subscripts and superscripts in a RichTextBox control. To prevent the control from truncating text that is raised or lowered too far, reduce the characters' size accordingly:

 Private Sub Form_Load()
	RichTextBox1.Font.Name = "Times New Roman"
	RichTextBox1.Font.Size = 10
	RichTextBox1.Text = "H2SO4"

' Move the numbers down 2 points.
	MakeSubscript RichTextBox1, 1, 1, -2
	MakeSubscript RichTextBox1, 4, 1, -2
End Sub

Private Sub OffsetRichText(box As _
	RichTextBox, start As Integer, _
	length As Integer, offset As Integer)
		box.SelStart = start
		box.SelLength = length
		box.SelFontSize = box.Font.Size + offset
		box.SelCharOffset = -ScaleY(offset, _
			vbPoints, vbTwips)
		box.SelStart = 0
		box.SelLength = 0
End Sub
Rod Stephens
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date