<%
ss = "one,two,three,four,five,six,seven,eight,nine"
ds = "ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen," & _
"seventeen,eighteen,nineteen"
ts = "twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety"
qs = ",thousand,million,billion"
Function nnn2words(iNum)
a = split(ss,",")
i = iNum mod 10
if i > 0 then s = a(i-1)
ii = int(iNum mod 100)\10
if ii = 1 then
s = split(ds,",")(i)
elseif ((ii>1) and (ii<10)) then
s = split(ts,",")(ii-2) & " " & s
end if
i = (iNum \ 100) mod 10
if i > 0 then s = a(i-1) & " hundred " & s
nnn2words = s
End Function
Function num2words(iNum)
i = iNum
if i < 0 then b = true: i = i*-1
if i = 0 then
s="zero"
elseif i <= 2147483647 then
a = split(qs,",")
for j = 0 to 3
iii = i mod 1000
i = i \ 1000
if iii > 0 then s = nnn2words(iii) & _
" " & a(j) & " " & s
next
else
s = "out of range value"
end if
if b then s = "negative " & s
num2words = trim(s)
End Function
I tried but it didn't work ...
$ss = "one,two,three,four,five,six,seven,eight,nine"
$ds = "ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen"
$ts = "twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety"
$qs = ",thousand,million,billion"
Func nnn2words($iNum)
$a = StringSplit($ss, ",")
$i = Mod($iNum, 10)
If $i > 0 Then
$s = $a($i - 1)
EndIf
$ii = int(Mod($iNum, 100)) / 10
If $ii = 1 Then
$s = StringSplit($ds, ",")($i)
ElseIf (($ii > 1) And ($ii < 10)) Then
$s = StringSplit($ts, ",")($ii - 2) & " " & $s
EndIf
$i = Mod(($iNum / 100), 10)
If $i > 0 Then $s = $a($i - 1) & " hundred " & $s
$nnn2words = $s
EndFunc
Func num2words($iNum)
$i = $iNum
If $i < 0 Then
$b = True
$i = $i * -1
EndIf
If $i = 0 Then
$s = "zero"
ElseIf $i <= 2147483647 Then
$a = StringSplit($qs, ",")
For $j = 0 to 3
$iii = Mod($i, 1000)
$i = $i / 1000
If $iii > 0 Then $s = nnn2words($iii) & " " & $a($j) & " " & $s
Next
Else
$s = "out of range value"
EndIf
If $b Then $s = "negative " & $s
num2words = StringTrimLeft($s)
EndFunc
Thanks for your help!