The program recently made the contract part of the project to use the need to be able to transfer the digital English program, looked for a lot of sites are useless, can only get down to do their own, the process is not too concise, but the function can be achieved, perhaps colleagues will be useful. (VBScript)
function Zr4 (y) ' Prepare data
Dim Z (10)
Z (1) = "One"
Z (2) = "Two"
Z (3) = "THREE"
Z (4) = "FOUR"
Z (5) = "FIVE"
Z (6) = "SIX"
Z (7) = "SEVEN"
Z (8) = "Eight"
Z (9) = "NINE"
Zr4=z (MID (y,1,1))
End Function
function Zr3 (y) ' Prepare data
Dim Z (10)
Z (1) = "One"
Z (2) = "Two"
Z (3) = "THREE"
Z (4) = "FOUR"
Z (5) = "FIVE"
Z (6) = "SIX"
Z (7) = "SEVEN"
Z (8) = "Eight"
Z (9) = "NINE"
Zr3=z (MID (y,3,1))
End Function
function zr2 (y) ' Prepare data
Dim Z (20)
Z (Ten) = "TEN"
Z (one) = "Eleven"
Z (IN) = "Twelve"
z = "Thirteen"
z = "Fourteen"
z = "Fifteen"
Z (= "Sixteen")
z = "Seventeen"
Z (+) = "Eighteen"
z = "Nineteen"
Zr2=z (MID (y,2,2))
End Function
function zr1 (y) ' Prepare data
Dim Z (10)
Z (1) = "TEN"
Z (2) = "Twenty"
Z (3) = "Thirty"
Z (4) = "Forty"
Z (5) = "Fifty"
Z (6) = "Sixty"
Z (7) = "Seventy"
Z (8) = "Eighty"
Z (9) = "Ninety"
Zr1=z (MID (y,2,1))
End Function
function dw (y) ' Prepare data
Dim Z (5)
Z (0) = ""
Z (1) = "thousand"
Z (2) = "Million"
Z (3) = "billion"
Dw=z (y)
End Function
function W2 (y) ' used to make 2 digits to English
If MID (y,2,1) = "0" Then ' is judged to be less than 10
Value=zr3 (y)
ElseIf MID (y,2,1) = "1" then "judge whether between ten to 20
VALUE=ZR2 (y)
ElseIf MID (y,3,1) = "0" then "determines whether the number greater than 20 is divisible by 10 (in order to remove the trailing space)
VALUE=ZR1 (y)
Else
VALUE=ZR1 (y) + "" +zr3 (y) ' plus 10-bit to single-digit spaces
End If
W2=value
End Function
function W3 (y) ' used to make 3 digits to English
If MID (y,1,1) = "0" Then ' is judged to be less than 100
Value=w2 (y)
ElseIf MID (y,2,2) = "Then" to determine whether divisible by 100
Value=zr4 (y) + "" + "Hundred"
Else
Value=zr4 (y) + "" + "hundred" + "+" and "+" "+w2 (y)" cannot be divisible by adding "and"
End If
W3=value
End Function
function make (x)
Z=instr (1,x, ".", 1) ' Take the decimal place
If Z<>0 then ' judge if there's no decimal
Lstr=mid (x,1,z-1) ' Take the string to the left of the decimal point
Rstr=mid (x,z+1,2) ' Take the string to the right of the decimal point
Else
Lstr=x ' No decimal situation
End If
Lstrev=strreverse (LSTR) ' strings to the left string
Dim A (5) ' defines 5 string variables that are used to hold parsed three-bit sets of strings
Select Case len (lstrev) MoD 3 string length cannot be divisible and must be padded
Case "1"
lstrev=lstrev+ "00"
Case "2"
lstrev=lstrev+ "0"
End Select
Lm= "" ' is used to store the converted integer part
For I=0 to Len (lstrev)/3-1 ' Calculate how many three-bit
A (i) =strreverse (Mid (lstrev,3*i+1,3)) ' intercept 1th three-bit
If a (i) <> "then" is used to avoid this situation "1000000=one million thousand Only"
If I<>0 Then
LM=W3 (A (i)) + "" +DW (i) + "" +LM "used to add" thousand or million or billion "
Else
LM=W3 (A (i)) "I=0" LM=W3 (A (i)) + "" +DW (i) + "+LM" extra two trailing spaces
End If
Else
LM=W3 (A (i)) +lm
End If
NEXT
Xs= "" ' to store the converted decimal parts
If Z<>0 Then
Xs= "and CENTS" + "" +W2 ("$" +rstr) + "'" ' ' decimal part exists when converting decimal parts
End If
make=lm+ "" +xs+ "only" ' final result, plus only
End Function