<%
Function NumToString(nNumber)
Dim bNegative
Dim bHundred
If nNumber < 0 Then
bNegative = True
End If
nNumber = Abs(Int(nNumber))
If nNumber < 1000 Then
If nNumber \ 100 > 0 Then
NumToString = NumToString & _
NumToString(nNumber \ 100) & " Hundred"
bHundred = True
nNumber = nNumber - ((nNumber \ 100) * 100)
Dim bNoFirstDigit
bNoFirstDigit = False
Select Case nNumber \ 10
Case 0
Select Case nNumber Mod 10
If Not bHundred Then
NumToString = NumToString & " Zero"
Case 1: NumToString = NumToString & " One"
Case 2: NumToString = NumToString & " Two"
Case 3: NumToString = NumToString & " Three"
Case 4: NumToString = NumToString & " Four"
Case 5: NumToString = NumToString & " Five"
Case 6: NumToString = NumToString & " Six"
Case 7: NumToString = NumToString & " Seven"
Case 8: NumToString = NumToString & " Eight"
Case 9: NumToString = NumToString & " Nine"
End Select
bNoFirstDigit = True
Case 1
Case 0: NumToString = NumToString & " Ten"
Case 1: NumToString = NumToString & " Eleven"
Case 2: NumToString = NumToString & " Twelve"
Case 3: NumToString = NumToString & " Thirteen"
Case 4: NumToString = NumToString & " Fourteen"
Case 5: NumToString = NumToString & " Fifteen"
Case 6: NumToString = NumToString & " Sixteen"
Case 7: NumToString = NumToString & " Seventeen"
Case 8: NumToString = NumToString & " Eighteen"
Case 9: NumToString = NumToString & " Nineteen"
Case 2: NumToString = NumToString & " Twenty"
Case 3: NumToString = NumToString & " Thirty"
Case 4: NumToString = NumToString & " Forty"
Case 5: NumToString = NumToString & " Fifty"
Case 6: NumToString = NumToString & " Sixty"
Case 7: NumToString = NumToString & " Seventy"
Case 8: NumToString = NumToString & " Eighty"
Case 9: NumToString = NumToString & " Ninety"
If Not bNoFirstDigit Then
If nNumber Mod 10 <> 0 Then
NumToString = NumToString & "-" & _
Mid(NumToString(nNumber Mod 10), 2)
Else
Dim nTemp
nTemp = 10 ^ 12 'trillion
Do While nTemp >= 1
If nNumber >= nTemp Then
NumToString(Int(nNumber / nTemp))
Select Case Int(Log(nTemp) / Log(10) + 0.5)
Case 12: NumToString = NumToString & " Trillion"
Case 9: NumToString = NumToString & " Billion"
Case 6: NumToString = NumToString & " Million"
Case 3: NumToString = NumToString & " Thousand"
nNumber = nNumber - (Int(nNumber / nTemp) * nTemp)
nTemp = nTemp / 1000
Loop
If bNegative Then
NumToString = " negative" & NumToString
End Function
Function DollarToString(nAmount)
Dim nDollar
Dim nCent
nDollar = Int(nAmount)
nCent = (Abs(nAmount) * 100) Mod 100
DollarToString = NumToString(nDollar) & " Dollar"
If Abs(nDollar) <> 1 Then
DollarToString = DollarToString & "s"
DollarToString = DollarToString & " and" & _
NumToString(nCent) & " cent"
If Abs(nCent) <> 1 Then
Response.Write NumToString(1258966)
%>