| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Superscript Function
I made this function for my own use, but here you go. Send it the number you want (1, 2, 3, 4) and it will return the number back with correct superscript (1st, 2nd, 3rd, 4th...)
Code:
Function SuperScript(intValue) If IsNumeric(intValue) Then Dim intNumber1, intNumber2, intOutput intNumber1 = CLng(Right(intValue,1)) intNumber2 = CLng(Right(intValue,2)) If intValue <= 0 Then intOutput = Null ElseIf intNumber2 = 11 Or intNumber2 = 12 Or intNumber2 = 13 Then intOutput = "th" Else If intNumber1 = 1 Then intOutput = "st" ElseIf intNumber1 = 2 Then intOutput = "nd" ElseIf intNumber1 = 3 Then intOutput = "rd" Else intOutput = "th" End If End If SuperScript = intValue & "<span style=""vertical-align: super; font-size: 7pt;"">" & intOutput & "</span>" Else SuperScript = Null End If End Function
__________________
www.xoise.com - www.ourfreegames.com - www.playtouchgames.com - www.randomtools.net - www.xenocide-rpg.com Last edited by baseballdude_ : January 3rd, 2006 at 08:36 AM. Reason: Code Revision |
|
#2
|
||||
|
||||
|
hmm...
Code:
bad1=SuperScript("hackhack")
bad2=SuperScript(0) 'or SuperScript(-99) or any negative
bad3=SuperScript(11) 'as far as I know it should be 11th not 11st
only teasing, it's nice and useful code - only the last "bad" really need fix, the others are not likely to happen. ![]() |
|
#3
|
||||
|
||||
|
Good catch on the 11 Shadow, didn't think that one through...the others definitely won't matter to me, as I draw the number from the database, and it's an auto-incrementing number starting at 1
![]() I'll rewrite it for all cases anyway ![]() |
|
#4
|
||||
|
||||
|
close, but only half cigar: what about 111 or 1111?
![]() |
|
#5
|
||||
|
||||
|
Quote:
One last try then, eh? ![]() |
|
#6
|
||||
|
||||
|
Quote:
and... congrats for the 1500th post!! ![]() |
|
#7
|
||||
|
||||
|
Hehe, thanks
![]() Roughly 1/10 of your total posts ![]() |
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Superscript Function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|