早教吧作业答案频道 -->其他-->
vb阿拉伯数字变汉字a=1996现在要编写一个函数,把变量a变成一千九百九十六也就是阿拉伯数字变小写汉字!
题目详情
vb 阿拉伯数字变汉字
a=1996
现在要编写一个函数,把变量a变成 一千九百九十六
也就是阿拉伯数字变小写汉字!
a=1996
现在要编写一个函数,把变量a变成 一千九百九十六
也就是阿拉伯数字变小写汉字!
▼优质解答
答案和解析
Function xx_to_dx(xx As Double) As String '小写转大写
Dim dx As String '大写输出
Dim dw As String
Dim su As String
Dim t As Integer
dw = "角元拾佰仟万拾佰仟亿拾佰仟"
su = "壹贰叁肆伍陆柒捌玖"
Dim s As String
s = Format(xx * 100, "0")
If Len(s) > 14 Then MsgBox ("数位超过千亿,不能转为大写.")
'初始输出字符串
If Right(s, 1) "0" Then
dx = Mid$(su, Val(Right(s, 1)), 1) + "分"
Else
dx = "正"
End If
s = Left(s, Len(s) - 1)
d = 1
Do While (s "")
t = Val(Right(s, 1)): s = Left(s, Len(s) - 1)
If t = 0 Then
dx = "零" + dx
Do
If d = 2 Or d = 6 Or d = 10 Then dx = Mid$(dw, d, 1) + dx
d = d + 1
t = Val(Right(s, 1)): s = Left(s, Len(s) - 1)
Loop Until (t 0)
End If
dx = Mid$(su, t, 1) + Mid$(dw, d, 1) + dx
d = d + 1
Loop
If Right(dx, 2) = "零正" Then dx = Left(dx, Len(dx) - 2) + "正"
xx_to_dx = dx
End Function
Private Sub Form_Load()
MsgBox xx_to_dx(1999)
End Sub
Dim dx As String '大写输出
Dim dw As String
Dim su As String
Dim t As Integer
dw = "角元拾佰仟万拾佰仟亿拾佰仟"
su = "壹贰叁肆伍陆柒捌玖"
Dim s As String
s = Format(xx * 100, "0")
If Len(s) > 14 Then MsgBox ("数位超过千亿,不能转为大写.")
'初始输出字符串
If Right(s, 1) "0" Then
dx = Mid$(su, Val(Right(s, 1)), 1) + "分"
Else
dx = "正"
End If
s = Left(s, Len(s) - 1)
d = 1
Do While (s "")
t = Val(Right(s, 1)): s = Left(s, Len(s) - 1)
If t = 0 Then
dx = "零" + dx
Do
If d = 2 Or d = 6 Or d = 10 Then dx = Mid$(dw, d, 1) + dx
d = d + 1
t = Val(Right(s, 1)): s = Left(s, Len(s) - 1)
Loop Until (t 0)
End If
dx = Mid$(su, t, 1) + Mid$(dw, d, 1) + dx
d = d + 1
Loop
If Right(dx, 2) = "零正" Then dx = Left(dx, Len(dx) - 2) + "正"
xx_to_dx = dx
End Function
Private Sub Form_Load()
MsgBox xx_to_dx(1999)
End Sub
看了 vb阿拉伯数字变汉字a=19...的网友还看了以下:
今年我市枇杷售价普遍上涨,王阿姨用360元从常太镇购进50千克枇杷,按质量分甲、乙两个等级卖出,甲 2020-05-13 …
王叔在超市买3千克苹果和5千克梨付34.5元,张阿姨也买了同样的苹果和梨各1千克,付9.5元,苹果 2020-05-13 …
学校食堂买了12.5千克茄子,9.8千克白菜、7.6千克萝卜.已知茄子每千克2.45元,白菜每千克 2020-05-13 …
0.8千克=()克3.68千克=()米4.8吨=()千克1.07米=()毫米5.7千克=()克3. 2020-05-21 …
思考题.小明家电表下半年每月月底读数如下:7月352千瓦时,8月378千瓦时,9月399千瓦时,1 2020-06-14 …
28万3千3百9十6块8毛用阿拉伯数字怎么写的,带小数点那种见笑了! 2020-06-15 …
购入材料,货款及增值税,款项未支付.怎么写借贷?1.7日,从南方公司购入A材料30000千克,每千 2020-06-30 …
某市出租车的收费标准如下表.(1)王叔叔乘出租车行了5千米,应付多少元?行驶里程收费3千米以内(含 2020-07-04 …
一个4位数乘9就倒转过来,这个数是什么?就是一个4位数乘9,就倒过来写.比如ABCD乘9就是DCB 2020-07-29 …
求水果糖几千克?超市用每千克13.2元的奶糖45千克,每千克14元的巧克力糖57千克和若干每千克9. 2020-11-16 …