<body><form action=numtochar.asp method=post>
<input name=num value="1234567.25">
<input type=submit></form>
<%
dim n1(10), n10(10), n100(7), num, pointaddr, cnum, ln, l
num = request.form("num")
n1(0)="": n1(1)="หนึ่ง": n1(2)="สอง": n1(3)="สาม": n1(4)="สี่": n1(5)="ห้า"
n1(6)="หก": n1(7)="เจ็ด": n1(8)="แปด": n1(9)="เก้า": n10(1)="สิบ"
n10(2)="ยี่สิบ": n10(3)="สามสิบ": n10(4)="สี่สิบ": n10(5)="ห้าสิบ": n10(6)="หกสิบ"
n10(7)="เจ็ดสิบ": n10(8)="แปดสิบ": n10(9)="เก้าสิบ": n100(7)="ล้าน"
n100(6)="แสน": n100(5)="หมื่น": n100(4)="พัน": n100(3)="ร้อย": n100(2)="สิบ"
pointaddr = instr(1,num,".")
if pointaddr > 0 then
usenum = left(num,pointaddr - 1)
restnum = left(right(num,len(num) - pointaddr),2)
else
usenum = num
end if
cnum = ""
ln = len(usenum)
for i = 1 to ln
n = cint(mid(usenum,i,1))
if i > ln - 2 then
if i = ln - 1 then
cnum = cnum + n10(n) ' หลักสิบ
else
cnum = cnum + n1(n) ' หลักหน่วย
end if
else
if n > 0 then
cnum = cnum + n1(n)
cnum = cnum + n100(ln - i + 1)
end if
end if
next
response.write(cnum)
if pointaddr = 0 or cdbl(num) = 0 then
if cdbl(num) = 0 then
response.write("ศูนย์บาท")
else
response.write("บาทถ้วน")
end if
else
cnum = "บาท"
ln = len(restnum)
for i = 1 to ln
n = cint(mid(restnum,i,1))
if ln > 1 and i = 1 then
cnum = cnum + n10(n)
else
if n = 1 and i <> 1 then
cnum = cnum + "เอ็ด"
else
cnum = cnum + n1(n)
end if
end if
next
response.write(cnum & "สตางค์")
end if
%>
</body>
จำนวน : 61 บรรทัด