| 
 | 
1. (C #): 
// Add to the definition part of the class 
private static string [] cstr = {"zero", "one", "贰", "three", "three", "wu", "lu", "柒", "捌", "玖"}; 
private static string [] wstr = {"", "", "pick up", "bai", "仟", "wan", "pick up", "bai", "仟", "billion", "pick up, "百", "仟"}; 
// A string whose number must be within a 12-digit integer 
// Call method such as: Label1.Text = ConvertInt ("numeric string"); 
 
public string ConvertInt (string str) 
{ 
int len = str.Length; 
int i; 
string tmpstr, rstr; 
rstr = ""; 
for (i = 1; i <= len; i ++) 
{ 
tmpstr = str.Substring (len-i, 1); 
rstr = string.Concat (cstr [Int32.Parse (tmpstr)] + wstr [i], rstr); 
} 
rstr = rstr.Replace ("pick up", "pick up"); 
rstr = rstr.Replace ("Zero Pickup", "Zero"); 
rstr = rstr.Replace ("零 百", "零"); 
rstr = rstr.Replace ("零 仟", "zero"); 
rstr = rstr.Replace ("zero million", "million"); 
for (i = 1; i <= 6; i ++) 
rstr = rstr.Replace ("zero zero", "zero"); 
rstr = rstr.Replace ("Zero million", "Zero"); 
rstr = rstr.Replace ("billion", "billion"); 
rstr = rstr.Replace ("zero zero", "zero"); 
rstr + = "rounded"; 
return rstr; 
} 
 
 
  
 
2. 
ASP code to convert case amount 
<% 
dim a 'Amount to be converted to upper case 
dim atoc 'converted value 
Dim String1 'as defined below 
Dim String2 'as defined below 
Dim String3 'The value taken from the original A value 
Dim I 'loop variable 
Dim J 'A value multiplied by 100 string length 
Dim Ch1 'Numbers in Chinese 
Dim Ch2 'Digital Chinese Characters 
Dim nZero 'is used to calculate the continuous zero value is several 
 
String1 = "零 一 贰 三 肆 伍 陆 柒 捌 玖" 
String2 = "One hundred million dollars One hundred million dollars One hundred million dollars One thousand yuan points" 
nZero = 0 
 
If InStr (1, CStr (a * 100), ".") <> 0 Then 
err.Raise 5000,, "This function (AtoC ()) can only convert numbers with less than two decimal places!" 
End If 
 
J = Len (CStr (a * 100)) 
String2 = Right (String2, J) 'Remove the value of STRING2 with the corresponding number of digits 
 
For I = 1 To J 
String3 = Mid (a * 100, I, 1) 'Remove the value of a bit to be converted 
 
If I <> (J-3) + 1 And I <> (J-7) + 1 And I <> (J-11) + 1 And I <> (J-15) + 1 Then 
If String3 = 0 Then 
Ch1 = "" 
Ch2 = "" 
nZero = nZero + 1 
ElseIf String3 <> 0 And nZero <> 0 Then 
Ch1 = "zero"&Mid (String1, clng (String3) + 1, 1) 
Ch2 = Mid (String2, I, 1) 
nZero = 0 
Else 
Ch1 = Mid (String1, clng (String3) + 1, 1) 
Ch2 = Mid (String2, I, 1) 
nZero = 0 
End If 
Else 'This bit is the key bit of trillion, billion, million, yuan, etc. 
If String3 <> 0 And nZero <> 0 Then 
Ch1 = "zero"&Mid (String1, clng (String3) + 1, 1) 
Ch2 = Mid (String2, I, 1) 
nZero = 0 
ElseIf String3 <> 0 And nZero = 0 Then 
Ch1 = Mid (String1, clng (String3) + 1, 1) 
Ch2 = Mid (String2, I, 1) 
nZero = 0 
ElseIf String3 = 0 And nZero> = 3 Then 
Ch1 = "" 
Ch2 = "" 
nZero = nZero + 1 
Else 
Ch1 = "" 
Ch2 = Mid (String2, I, 1) 
nZero = nZero + 1 
End If 
 
If I = (J-11) + 1 Or I = (J-3) + 1 Then 'If the bit is a billion or a bit, you must write 
Ch2 = Mid (String2, I, 1) 
End If 
 
End If 
AtoC = AtoC&Ch1&Ch2 
 
If I = J And String3 = 0 Then 'When the last digit (point) is 0, add "whole" 
AtoC = AtoC&"Whole" 
End If 
 
Next 
if a = 0 then 
atoc = "零 元 整" 
end if 
%> 
 
 
  
 
3. 
<!-# include file = common.asp-> 
<% 
dim tmpnum 
'Lower case amount from the first page 
tmpnum = request ("page1num") 
'Call and display capitalized amount 
response.write rmb (cdbl (tmpnum)) 
response.end 
%> 
 
 
common.asp 
<% 
Function rmb (num) 
 
num = FormatNumber (num, 2) 
Dim numList 
Dim rmbList 
Dim numLen 
Dim numChar 
Dim numstr 
Dim n 
Dim n1, n2 
Dim hz 
numList = "零 一 贰 三 肆 伍 陆 柒 捌 玖" 
rmbList = "Diagonal Yuan Shi Bai Shi Wan Shi Bai Shi Wan Shi Bai Shi Wan Bai Shi Wan Wan" 
 
If num> 9999999999999.99 Then 
rmb = "Out of range RMB value" 
Exit Function 
End If 
 
numstr = CStr (num * 100) 
numLen = Len (numstr) 
n = 1 
Do While n <= numLen 
numChar = CInt (Mid (numstr, n, 1)) 
n1 = Mid (numList, numChar + 1, 1) 
n2 = Mid (rmbList, numLen-n + 1, 1) 
If Not n1 = "zero" Then 
hz = hz + CStr (n1) + CStr (n2) 
Else 
If n2 = "billion" Or n2 = "million" Or n2 = "yuan" Or n1 = "zero" Then 
Do While Right (hz, 1) = "zero" 
hz = Left (hz, Len (hz)-1) 
Loop 
End If 
If (n2 = "billion" Or (n2 = "million" And Right (hz, 1) <> "billion") Or n2 = "yuan") Then 
hz = hz + CStr (n2) 
Else 
If Left (Right (hz, 2), 1) = "zero" Or Right (hz, 1) <> "billion" Then 
hz = hz + n1 
End If 
End If 
End If 
n = n + 1 
Loop 
Do While Right (hz, 1) = "zero" 
hz = Left (hz, Len (hz)-1) 
Loop 
If Right (hz, 1) = "Yuan" Then 
hz = hz + "whole" 
End If 
rmb = hz 
End Function 
 
%> 
 
 
This version solves the problem that the decimal place cannot reach the point, and the processing method conforms to the accounting method! 
 
 
  
 
4. 
A completely error-free version of the amount of case conversion 
 
 
<!-# include file = common.asp-> 
<% 
dim tmpnum 
'Lower case amount from the first page 
tmpnum = request ("page1num") 
'Call and display capitalized amount 
response.write rmb (cdbl (tmpnum)) 
response.end 
%> 
 
 
A completely error-free version of the amount of case conversion 
 
 
<!-# include file = common.asp-> 
<% 
dim tmpnum 
'Lower case amount from the first page 
tmpnum = request ("page1num") 
'Call and display capitalized amount 
response.write rmb (cdbl (tmpnum)) 
response.end 
%> 
 
 
common.asp 
<% 
Function rmb (num) 
 
num = FormatNumber (num, 2) 
Dim numList 
Dim rmbList 
Dim numLen 
Dim numChar 
Dim numstr 
Dim n 
Dim n1, n2 
Dim hz 
numList = "零 一 贰 三 肆 伍 陆 柒 捌 玖" 
rmbList = "Diagonal Yuan Shi Bai Shi Wan Shi Bai Shi Wan Shi Bai Shi Wan Bai Shi Wan Wan" 
 
If num> 9999999999999.99 Then 
rmb = "Out of range RMB value" 
Exit Function 
End If 
 
numstr = CStr (num * 100) 
numLen = Len (numstr) 
n = 1 
Do While n <= numLen 
numChar = CInt (Mid (numstr, n, 1)) 
n1 = Mid (numList, numChar + 1, 1) 
n2 = Mid (rmbList, numLen-n + 1, 1) 
If Not n1 = "zero" Then 
hz = hz + CStr (n1) + CStr (n2) 
Else 
If n2 = "billion" Or n2 = "million" Or n2 = "yuan" Or n1 = "zero" Then 
Do While Right (hz, 1) = "zero" 
hz = Left (hz, Len (hz)-1) 
Loop 
End If 
If (n2 = "billion" Or (n2 = "million" And Right (hz, 1) <> "billion") Or n2 = "yuan") Then 
hz = hz + CStr (n2) 
Else 
If Left (Right (hz, 2), 1) = "zero" Or Right (hz, 1) <> "billion" Then 
hz = hz + n1 
End If 
End If 
End If 
n = n + 1 
Loop 
Do While Right (hz, 1) = "zero" 
hz = Left (hz, Len (hz)-1) 
Loop 
If Right (hz, 1) = "Yuan" Then 
hz = hz + "whole" 
End If 
rmb = hz 
End Function 
 
%> 
 
 
 
 
5. 
<% function Money (thenumber) 
dim Money, i, String1, String2, length, checkp´ define variables 
dim one (), onestr ()´ define array 
 
String1 = "零 一 贰 三 肆 伍 陆 柒 捌 玖" 
String2 = "One hundred million dollars, one hundred million dollars, one hundred million dollars, one hundred and twenty cents" 
 
checkp = instr (thenumber, ".")´ determine whether it contains decimal places 
if checkp <> 0 then 
thenumber = replace (thenumber, ".", "")´ remove decimal places 
end if 
 
length = len (thenumber)´ Get data length 
redim one (length-1)´ redefine array size 
redim onestr (length-1)´ redefine array size 
 
for i = 0 to length-1 
 
one (i) = mid (thenumber, i + 1,1)´ get each digit 
one (i) = mid (string1, one (i) +1,1)´ loop to get the uppercase corresponding to the number 
 
 
if checkp = 0 then 
´ data without decimals corresponding to the unit of number 
onestr (i) = mid (string2,14-length + i, 1) 
else 
´ data containing decimals and its corresponding unit 
onestr (i) = mid (string2,15-length + i + len (thenumber) -checkp, 1) 
end if 
 
one (i) = one (i)&onestr (i)´ combine numbers and units 
next 
 
Money = replace (join (one), "", "")´ Get all elements in the array and connect them 
Money = replace (Money, "Zero", "Yuan") 
Money = replace (Money, "Zero million", "Million") 
Money = replace (Money, "billion", "billion") 
Money = replace (Money, "零 仟", "零") 
Money = replace (Money, "零 百", "零") 
Money = replace (Money, "Zero Pickup", "Zero") 
 
do while not instr (Money, "Zero Zero") = 0 
Money = replace (Money, "zero zero", "zero") 
loop 
 
response.write Money´ show results 
end function 
%> |   
 
 
 
 |