Daniel_Upton

New member
Joined
Jan 8, 2010
Messages
1
Programming Experience
1-3
Hi,

I am currently developing an application which generates scientific values and places them into a textbox..

For most of my textboxes this: txtBox1.Text = Format(value1, "0.00")
Works perfectly..

But for one of them i need to format the number in this: 1.48 * 10(with a 5 in super script representing to the power of 5) style.

The "big number" behind this example is: 1477895632.43816

Any help with this would be great cause this is driving me insane!

Thanks in advance
Dan
 
Using a font that support those "math" symbols is probably the easier option. There is no style that can be set for part of text to sup/sub it like in Html. Try the Windows Character Map app to see if a font exist with those superscript numbers, or perhaps just seek out a typical "math" font on the web. Most regular fonts only has 1-3 as superscript.

If you use RichTextBox you can format part of text to superscript with SelectionCharOffset property. An example that also decreases the font size for that selection:
VB.NET:
Me.RichTextBox1.Text = "1.48 * 105"
Me.RichTextBox1.Select(Me.RichTextBox1.TextLength - 1, 1)
Me.RichTextBox1.SelectionCharOffset = 5
Dim f As Font = Me.RichTextBox1.SelectionFont
Me.RichTextBox1.SelectionFont = New Font(f.FontFamily, f.Size - 2)
 

Latest posts

Back
Top