vb 完成转换功能 小写转换为大写金额 ④⑤⑥三个空怎么填空 拜托了 ④⑤⑥
答案:1 悬赏:50 手机版
解决时间 2021-04-01 00:12
- 提问者网友:送舟行
- 2021-03-31 04:16
vb 完成转换功能 小写转换为大写金额 ④⑤⑥三个空怎么填空 拜托了 ④⑤⑥
最佳答案
- 五星知识达人网友:痴妹与他
- 2021-03-31 04:31
④ t = Val(Mid(str, i, 1))
⑤ endStr = endStr + num(t) + unit(Len(str) - i)
⑥ Text2.Text = endStr+"元"
全部代码:
Private Sub Command1_Click()
Dim num, unit$(3), str$, t%, strlen%, endStr$
num = Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖")
unit(1) = "拾": unit(2) = "佰": unit(3) = "仟"
Dim haveZero As Boolean
str = (Text1.Text)
If Len(str) > 4 Or Val(str) <= 0 Then
Text2.Text = "数据不合法,请重新输入"
Text1.SetFocus
Exit Sub
End If
For i = 1 To Len(str)
If Mid(str, i, 1) <> "0" Then str = Mid(str, i, Len(str)): Exit For
Next i
For i = 1 To Len(str)
t = Val(Mid(str, i, 1))
If t = 0 Then
haveZero = True
Else
If haveZero Then
endStr = endStr + "零" + num(t) + unit(Len(str) - i)
Else
endStr = endStr + num(t) + unit(Len(str) - i)
End If
End If
Next i
Text2.Text = endStr+"元"
End Sub运行效果界面:
追问如果说要把小数取出来呗呢就是多少角多少分都要显示
⑤ endStr = endStr + num(t) + unit(Len(str) - i)
⑥ Text2.Text = endStr+"元"
全部代码:
Private Sub Command1_Click()
Dim num, unit$(3), str$, t%, strlen%, endStr$
num = Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖")
unit(1) = "拾": unit(2) = "佰": unit(3) = "仟"
Dim haveZero As Boolean
str = (Text1.Text)
If Len(str) > 4 Or Val(str) <= 0 Then
Text2.Text = "数据不合法,请重新输入"
Text1.SetFocus
Exit Sub
End If
For i = 1 To Len(str)
If Mid(str, i, 1) <> "0" Then str = Mid(str, i, Len(str)): Exit For
Next i
For i = 1 To Len(str)
t = Val(Mid(str, i, 1))
If t = 0 Then
haveZero = True
Else
If haveZero Then
endStr = endStr + "零" + num(t) + unit(Len(str) - i)
Else
endStr = endStr + num(t) + unit(Len(str) - i)
End If
End If
Next i
Text2.Text = endStr+"元"
End Sub运行效果界面:
追问如果说要把小数取出来呗呢就是多少角多少分都要显示
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯