Maybe read the title will be a bit fog, it doesn't matter, look at the following function to understand, the process is to 123 such a turn into 123.
Turn a string of numbers into a corresponding Chinese character
function Convertnumtostr (pnum)
Dim onum,rvalue
Onum=pnum:rvalue= ""
' If the given is not a reasonable number, then return the empty string
If not Checkpattern (Onum,z_patnum) 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, "1")
Rljc.pattern= "^0{2,} (\.)"
Onum=rljc.replace (Onum, "01")
' 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
' Convert the following decimal point
If backnum<> "" Then
Strback= ""
For I=1 to Len (backnum)
Strback=strback & Convertnumtocc (Mid (backnum,i,1))
Next
Rvalue=rvalue & "Dot" & Strback
End If
Convertnumtostr=rvalue
End Function
"Converts a number to the corresponding Chinese character
function Convertnumtocc (pnum)
Select Case Pnum
Case 1:convertnumtocc= "one"
Case 2:convertnumtocc= "two"
Case 3:convertnumtocc= "three"
Case 4:convertnumtocc= "Four"
Case 5:convertnumtocc= "Five"
Case 6:convertnumtocc= "Six"
Case 7:convertnumtocc= "Seven"
Case 8:convertnumtocc= "eight"
Case 9:convertnumtocc= "Nine"
Case 0:convertnumtocc= "0"
End Select
End Function
' Returns the corresponding Chinese characters according to the number of digits
function Getdigit (odigit)
if (odigit+2) mod 4=0 Then
Getdigit= "Ten"
ElseIf (odigit + 1) mod 4=0 Then
Getdigit= "Hundred"
ElseIf odigit MoD 4=0 Then
getdigit= "Thousand"
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
Haha, it's great. Sometimes (especially in the more formal case), the Chinese character format better