Flo Flo - 2 years ago 115
Vb.net Question

Superscript price decimal numbers when using Standard Numeric Format Strings

I'm using Standard Numeric Format Strings (see here) to format pricing on my page:

Dim price As Integer = 378
Dim s As String = (CDec(price) / 100).ToString("F")

results in string "3,78" which I print in HTML.

However, I want the decimal part "78" to be superscripted using HTML/CSS. How can I do so?

Answer Source

Unless the text is automatically HTML encoded (and you have access to the source of all this) you can use the <sup> tag.

To superscript only the 78 part just split the string by , (or . if that is the case) into an array and join it together again with the tag included.

For example:

Dim Parts() As String = s.Split(If(s.Contains("."), ".", ","))
Dim s2 As String = Parts(0) & ",<sup>" & Parts(1) & "</sup>"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download