ASP version: <% 'document name: CMYCUR.ASP' Server: Twenty-four Paintings 'version: 1.0' Simple Due: Convert Function File. 'Features Description: Transfer the function of currency form. (This file contains two functions, one converted into a general currency form CMYCUR (NUM), a converted into capital form CMYCURD (NUM))%> <% Function CMYCUR (NUM) 'Convert to currency forms such as: ¥ 180.00 DIM THENUM IF isnull (NUM) or Num = "" "" "" "" NUM is the value of the DIM STR3 ', the DIM STR3' is defined below the value of the DIM STR3 ', the value DIM I' cyclic variable DIM J 'Num is multiplied by 100 string length DIM CH1'. Digital Chinese Reading DIM CH2 'Digital Bit Dimense DIM NZERO' is used to calculate a continuous zero value is a few
STR1 = "Zero Zi Zi Lu Lu" STR2 = "Wan Yiyi picks up hundreds of millions of people" NZERO = 0 if isnull (NUM) or Num = "" THEN CMYCURD = " "EXIT FUNCTION END IF NUM = Round (ABS (NUM), 2) 'Take Num Remove the Num and Take 2 Decons J = LEN (CSTR (Num * 100))' to find the highest bit if j> 15 THEN CMYCURD = "Spill" exit function end if str2 = right (str2, j) 'Remove the value of STR2 of the corresponding number.
Such as: 200.55, J is 5, so str2 = 拾 元 'cycle Removes each of the values that need to be converted for i = 1 to j str3 = MID (NUM * 100, I, 1)' Take a certain one to be converted Bits IF i <> (j - 3) 1 and i <> (j - 7) 1 and i <> (j - 11) 1 and i <> (j - 15) 1 THEN ' Number of nested is not Yuan, Wan, billion, trillion when IF str3 = 0 THEN CH1 = "" CH2 = "" NZERO = NZERO 1 elseif str3 <> 0 and Nzero <> 0 THEN CH1 = "zero "& MID (STR1, CLNG (STR3) 1, 1) CH2 = MID (STR2, I, 1) NZERO = 0 else CH1 = MID (STR1, CLNG (STR3) 1, 1) CH2 = MID (STR2, I, 1) NZERO = 0 end if else 'This bit is trillion, billion, million, yuan, key IF str3 <> 0 and Nzero <> 0 THEN CH1 = "Zero" & MID (STR1, CLNG (STR3 ) 1, 1) CH2 = MID (STR2, I, 1) Nzero = 0 elseif str3 <> 0 and Nzero = 0 TH1 = MID (STR1, CLNG (STR3) 1, 1) CH2 = MID (STR2, I, 1) Nzero = 0 elseif str3 = 0 and Nzero> = 3 Ten CH1 = "" CH2 = "" NZERO = NZERO 1 Elseif J> 10 Then 'When the whole hundreds of millions, it will add more than one million. Therefore, this situation removes CH1 = "" NZERO = NZERO 1 ELSE CH1 = "" CH2 = MID (STR2, I, 1) NZERO = NZERO 1 end if IF i = (j - 11) 1 or i = (j - 3) 1 Then 'If the bit is 100 million Or the Yuan Link must be written on CH2 = MID (STR2, I, 1) end if End ifcmycurd = CMYCURD & CH1 & CH2
If i = j and str3 = 0 THEN 'Last bit (minute) is 0, plus "whole" cmycurd = CMYCURD & "whole" end if nextif num = 0 THEN CMYCURD = "Zero Yuan" end ifnd function% >
JavaScript version: Function CMYCURD (NUM) {// Transfer to RMB uppercase amount VAR str1 = 'zero 壹 贰 肆 柒捌 柒捌'; // 0-9 Corresponding Chinese characters Var str2 = 'Wan Yi Yiliu picks up the 佰 佰 元 元 '; // The Chinese character VAR STR3 corresponding to the digital bit; // From the value VAR STR4; // digital string form VAR STR5 =' 'in the original NUM value; // RMB capital amount Form VAR i; // circulating variable var j; // Num multiply by 100 string length var ch1; // Digital Chinese reading VAR CH2; // Digital bits of Chinese characters reading var NZERO = 0; // Used to calculate a continuous zero value is a few num = math.abs (num) .tofixed (2); // Take Num to take the Num and take the number of 2 digits STR4 = (Num * 100) .tofixed (0) .tostring (); // multiply Num multiply 100 and convert into string form j = str4.Length; // to find the highest bit if (j> 15) {return 'overflow';} str2 = str2 .sustr (15-j); // Remove the value of the STR2 of the corresponding number.
Such as: 200.55, J is 5, so str2 = 拾 元 分 // Removes the value for each bit to be converted for For (i = 0; I
0 ') {// The last bit (minute) is 0, plus "whole" str5 = str5 ' whole ';}} if (num == 0) {STR5 =' zero element ';} returnof There is also a C # version of the C # version, the principle is almost, everyone wrote!