Private Function daxie(money As String) As String '声明变量
Dim X As String, Y As String
Const zimu = ".sbqwsbqysbqwsbq" '定义位置代码
Const letter = "0123456789sbqwy.jzf" '定义数字及汉字缩写
Const upcase = "零壹贰叁肆伍陆柒捌玖拾佰仟万亿圆角整分" '定义大写汉字
Dim temp As String
temp = money
If InStr(temp, ".") > 0 Then temp = Left(temp, InStr(temp, ".") - 1)
X = Format(money, "0.00") '格式化货币
Y = ""
For i = 1 To Len(X) - 3
Y = Y & Mid(X, i, 1) & Mid(zimu, Len(X) - 2 - i, 1)
Next
If Right(X, 3) = ".00" Then
Y = Y & "z" '***元整
Else
Y = Y & Left(Right(X, 2), 1) & "j" & Right(X, 1) & "f" '*元*角*分
End If
Y = Replace(Y, "0q", "0") '避免零千(如:40200肆万零千零贰佰,同样将前面的位置元素决定)
Y = Replace(Y, "0b", "0") '避免零百(如:41000肆万壹千零佰,如上)
Y = Replace(Y, "0s", "0") '避免零十(如:204贰佰零拾零肆如上)
Y = Replace(Y, "0j", "0") '避免零角
Y = Replace(Y, "0f", "整")
Do While Y <> Replace(Y, "00", "0")
Y = Replace(Y, "00", "0") '避免双零(如:1004壹仟零零肆)
Loop
Y = Replace(Y, "0y", "y") '避免零亿(如:210亿 贰佰壹十零亿)
Y = Replace(Y, "0w", "w") '避免零万(如:210万 贰佰壹十零万)
Y = IIf(Len(X) = 5 And Left(Y, 1) = "1", Right(Y, Len(Y) - 1), Y) '避免壹十(如:14壹拾肆;10壹拾)
Y = IIf(Len(X) = 4, Replace(Y, "0.", ""), Replace(Y, "0.", ".")) '避免零元(如:20.00贰拾零圆;0.12零圆壹角贰分)
For i = 1 To 19
Y = Replace(Y, Mid(letter, i, 1), Mid(upcase, i, 1)) '大写汉字
Next
daxie = Y
End Function
Private Sub Command1_Click()
Text2.Text = daxie(Val(Text1.Text)) ' (如return: 贰玖仟叁佰贰拾贰圆叁角贰分
Text2.FontSize = "18"
Text2.FontName = "幼圆"
End Sub
Private Sub Command2_Click()
Text1.Text = "0"
Text2.Text = "零"
End Sub
Private Sub Form_Load()
End Sub
谁能解释这段代码每句代码的意思 要详细 急用到明天中午
2009-9-1512:00