金额大小写转换
发布网友
发布时间:2022-04-23 14:36
我来回答
共4个回答
热心网友
时间:2022-04-28 12:13
1。将0到9数字的大写存入数组,与数字一一对应。如:Str(0)="零"……小数点另行定义
2。用循环依次取上文本框中的数字
3。for i=0 to len(text1)-1
inta=val(mid(i,1))'不是小数点的
text2=text2 & str(inta)
next
以上提供一种思路,未列出小数点的解法,具体你可以参考一下,方法有多种。
热心网友
时间:2022-04-28 13:31
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 = "分角元拾佰仟万拾佰仟亿拾佰仟万"
If num > 9999999999999.99 Then
RMB = "超出范围的人民币值"
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 = "零" Then
hz = hz + CStr(n1) + CStr(n2)
Else
If n2 = "亿" Or n2 = "万" Or n2 = "元" Or n1 = "零" Then
Do While Right(hz, 1) = "零"
hz = Left(hz, Len(hz) - 1)
Loop
End If
If (n2 = "亿" Or (n2 = "万" And Right(hz, 1) <> "亿") Or n2 = "元") Then
hz = hz + CStr(n2)
Else
If Left(Right(hz, 2), 1) = "零" Or Right(hz, 1) <> "亿" Then
hz = hz + n1
End If
End If
End If
n = n + 1
Loop
Do While Right(hz, 1) = "零"
hz = Left(hz, Len(hz) - 1)
Loop
If Right(hz, 1) = "元" Then
hz = hz + "整"
End If
RMB = hz
End Function
热心网友
时间:2022-04-28 15:06
你的邮箱?我发给你。
热心网友
时间:2022-04-28 16:57
小写与大写的定义?请举例子!