Use Subscripts and Superscripts

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, -2End SubPrivate 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 = 0End Sub

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist