ASP 版:
<%
'文 件 名:cmycur.asp
'作 者:二十四画生
'版 本:1.0
'简 介:转换函数文件。
'功能描述:转换货币形式的函数。(该文件包含两个函数,一个转换成一般货币形式cmycur(num),一个转换成大写形式cmycurd(num))
%>
<%
function cmycur(num) '转换为货币形式如:¥180.00元
dim thenum
if isnull(num) or num = "" then
cmycur = " "
else
num = Round(num,2)
thenum = FormatCurrency(num,2,-1)
cmycur = thenum & "元"
end if
end function
function cmycurd(num) 'num为要转换成大写的金额
dim str1 '如下定义
dim str2 '如下定义
dim str3 '从原num值中取出的值
dim i '循环变量
dim j 'num的值乘以100的字符串长度
dim ch1 '数字的汉语读法
dim ch2 '数字位的汉字读法
dim nzero '用来计算连续的零值是几个
str1 = "零壹贰叁肆伍陆柒捌玖"
str2 = "万仟佰拾亿仟佰拾万仟佰拾元角分"
nzero = 0
if isnull(num) or num = "" then
cmycurd = " "
exit function
end if
num = Round(Abs(num),2) '将num取绝对值并四舍五入取2位小数
j = Len(CStr(num * 100)) '找出最高位
if j > 15 then
cmycurd = "溢出"
exit function
end if