求助纠错小程序,求各位大侠们的帮助
本来刚学没多久,想做个从数字转化为中文大写的小程序,可是当我输入“1”时,结果为 “壹拾壹” “2”时,结果为“贰拾贰”“123”时结果为 “壹仟壹佰贰拾”叁 。Dim f, l, i As Integer
Dim y As String
Dim b As String
Dim t As String
f = Val(TextBox3.Text) ’先将输入框转成数字,以便将字符去除
b = Str(f) ’再将数字转为文
l = Len(b) ’求输入文本的长度
For i = 1 To l ’对输入文本的最后一位开始,一位一位的转为中文大写的中文字符
Select Case Mid$(b, l - i + 1, 1)
Case 0
y = "零"
Case 1
y = "壹"
Case 2
y = "贰"
Case 3
y = "叁"
Case 4
y = "肆"
Case 5
y = "伍"
Case 6
y = "陆"
Case 7
y = "柒"
Case 8
y = "捌"
Case 9
y = "玖"
Case 10
y = "拾"
End Select
t = t & y ’将转换后的中文字符以原字符的最后一位为开始,一个一个相接,若输入时为“123”,则t为“叁贰壹”
Next i
Select Case Len(t) ‘对不同的输入长度作不同的输出判断
Case 1
TextBox4.Text = t
Case 2
TextBox4.Text = Mid$(t, 2, 1) & "拾" & Mid$(t, 1, 1)
Case 3
TextBox4.Text = Mid$(t, 3, 1) & "佰" & Mid$(t, 2, 1) & "拾" & Mid$(t, 1, 1)
Case 4
TextBox4.Text = Mid$(t, 4, 1) & "仟" & Mid$(t, 3, 1) & "佰" & Mid$(t, 2, 1) & "拾" & Mid$(t, 1, 1)
Case 5
TextBox4.Text = Mid$(t, 5, 1) & "万" & Mid$(t, 4, 1) & "仟" & Mid$(t, 3, 1) & "佰" & Mid$(t, 2, 1) & "拾" & Mid$(t, 1, 1)
Case 6
TextBox4.Text = Mid$(t, 6, 1) & "拾" & Mid$(t, 5, 1) & "万" & Mid$(t, 4, 1) & "仟" & Mid$(t, 3, 1) & "佰" & Mid$(t, 2, 1) & "拾" & Mid$(t, 1, 1)
Case 7
TextBox4.Text = Mid$(t, 7, 1) & "佰" & Mid$(t, 6, 1) & "拾" & Mid$(t, 5, 1) & "万" & Mid$(t, 4, 1) & "仟" & Mid$(t, 3, 1) & "佰" & Mid$(t, 2, 1) & "拾" & Mid$(t, 1, 1)
Case 8
TextBox4.Text = Mid$(t, 8, 1) & "仟" & Mid$(t, 7, 1) & "佰" & Mid$(t, 6, 1) & "拾" & Mid$(t, 5, 1) & "万" & Mid$(t, 4, 1) & "仟" & Mid$(t, 3, 1) & "佰" & Mid$(t, 2, 1) & "拾" & Mid$(t, 1, 1)
Case 9
TextBox4.Text = Mid$(t, 9, 1) & "亿" & Mid$(t, 8, 1) & "仟" & Mid$(t, 7, 1) & "佰" & Mid$(t, 6, 1) & "拾" & Mid$(t, 5, 1) & "万" & Mid$(t, 4, 1) & "仟" & Mid$(t, 3, 1) & "佰" & Mid$(t, 2, 1) & "拾" & Mid$(t, 1, 1)
End Select
End Sub