Vbscript| Capital | amount | lowercase
<%
'--------------------a set of functions that convert numbers to Chinese characters------------------------
' Author: northsnow
' Date: 20061007
' Call Method: A=convertnumtostr (' 1234.5678 ')
' function: Convert such a string 1234.5678 into one thousand Woocher points
"Converts a string of numbers to a corresponding Chinese character.
function Convertnumtostr () function convertnumtostr (pnum)
Dim onum,rvalue
Onum=pnum:rvalue= ""
' If the given is not a reasonable number, then return the empty string
Const z_patnum= "^d+ (. { 1}d+)? $ "
Set R=new regexp
R.pattern=z_patnum
R.ignorecase=false
R.global=false
If not r.test (Onum) Then
Convertnumtostr=rvalue
Exit function
End If
' Remove the useless 0 in front of the number
Set Rljc=new REGEXP
Rljc.pattern= "^0{2,} ([^.])"
Onum=rljc.replace (Onum, "$")
Rljc.pattern= "^0{2,} (.)"
Onum=rljc.replace (Onum, "0$1")
' Separate the decimal points before and after
Arrnum=split (Onum, ".")
Frontnum=arrnum (0)
Backnum= ""
If UBound (arrnum) >0 then Backnum=arrnum (1)
'----Convert the number before the decimal point----
Olen=len (Frontnum)
If Olen=1 then ' only one
RVALUE=CONVERTNUMTOCC (Frontnum)
ElseIf olen=2 Then ' only two-bit
if (Mid (frontnum,1,1)) <> "1" Then Rvalue=convertnumtocc (Mid (frontnum,1,1))
Rvalue=rvalue & Getdigit (2)
if (Mid (frontnum,2,1)) <> "0" then Rvalue=rvalue & Convertnumtocc (Mid (frontnum,2,1))
Else ' greater than two-bit situation
Dim Curpos,curnum,haszero
Haszero=false ' indicates that there was no connection between the 0
For I=1 to OLen
Curpos=olen-i + 1
Curnum=mid (frontnum,i,1)
If CInt (curnum) =0 Then ' the current number of digits is zero
Haszero=true
' When the current bit is million bits or billions of bits, it is processed
if (curPos-1) mod 4=0 and Curpos>4 Then
Rvalue=rvalue & Getdigit (CurPos)
End If
Else ' Current number is not 0
If Haszero Then
Rvalue=rvalue & "0"
Haszero=false
End If
Rvalue=rvalue & Convertnumtocc (curnum) & Getdigit (CurPos)
End If
Next
End If
Rvalue=rvalue & "Yuan"
' Convert the following decimal point
If backnum<> "" Then
Strback= ""
If Len (backnum) >2 Then
Backnum=left (backnum,2)
End If
For I=1 to Len (backnum)
Strback=strback & Convertnumtocc (Mid (backnum,i,1)) & GetDigit2 (i)
Next
Rvalue=rvalue & Strback
Else
Rvalue=rvalue & "Whole"
End If
Convertnumtostr=rvalue
End Function
"Converts a number to the corresponding Chinese character
function Convertnumtocc () function Convertnumtocc (pnum)
Select Case Pnum
Case 1:convertnumtocc= "one"
Case 2:convertnumtocc= "II"
Case 3:convertnumtocc= "three"
Case 4:convertnumtocc= "Restaurant"
Case 5:convertnumtocc= "WU"
Case 6:convertnumtocc= "Lu"
Case 7:convertnumtocc= "Qi"
Case 8:convertnumtocc= "BA"
Case 9:convertnumtocc= "JIU"
Case 0:convertnumtocc= "0"
End Select
End Function
' Returns the corresponding Chinese characters according to the number of digits
function Getdigit () function getdigit (odigit)
If Odigit=1 Then
ElseIf (odigit+2) mod 4=0 Then
getdigit= "Pick Up"
ElseIf (odigit + 1) mod 4=0 Then
getdigit= "Bai"
ElseIf odigit MoD 4=0 Then
getdigit= "Qian"
ElseIf (oDigit-1) mod 4=0 Then
if ((oDigit-1)/4) mod 2=0 Then
Getdigit= "billion"
Else
Getdigit= "Million"
End If
End If
End Function
function GetDigit2 () function getDigit2 (odigit)
If Odigit=1 Then
Getdigit2= "Corner"
ElseIf odigit=2 Then
getdigit2= "Min"
End If
End Function
Dim AAA
Aaa= "108765.54"
Response. Write AAA
Response. Write Convertnumtostr (AAA)
%>