用VB,通过一个命令按钮,将阿拉伯数字金额转化成汉字大写金额~~求大神啊~~~~

如题所述

Private Sub Command3_Click()
Dim i As Integer, k As Integer, l As Integer, m As Integer, tmp As String, s1 As String, s2 As String, s3 As String, s4 As String
tmp = Format(Trim(Text1.Text), "0.00")
l = InStr(1, tmp, ".")
k = Len(tmp)
For i = 1 To k ' k To 1 Step -1
s2 = Mid(tmp, i, 1)
s1 = ""
s3 = ""
If s2 <> "." Then
Select Case Val(s2)
Case 1
s1 = "壹"
Case 2
s1 = "贰"
Case 3
s1 = "叁"
Case 4
s1 = "肆"
Case 5
s1 = "伍"
Case 6
s1 = "陆"
Case 7
s1 = "柒"
Case 8
s1 = "捌"
Case 9
s1 = "玖"
Case 0
s1 = "零"
End Select

If i < l Then
m = l - i
Select Case m
Case 1
s3 = "圆"
Case 2
s3 = "拾"
Case 3
s3 = "佰"
Case 4
s3 = "仟"
Case 5
s3 = "万"
Case 6
s3 = "拾"
Case 7
s3 = "佰"
Case 8
s3 = "仟"
Case 9
s3 = "亿"
Case 10
s3 = "拾"
Case 11
s3 = "佰"
Case 12
s3 = "仟"
Case 13
s3 = "兆"
End Select
Else
If i > l Then
m = i - l
Select Case m

Case 2
s3 = "分"
Case 1
s3 = "角"
End Select
End If
End If
s4 = s4 & s1 & s3
End If
Next
Text2.Text = s4
End Sub
温馨提示:内容为网友见解,仅供参考
第1个回答  2012-10-26
Private Sub Command1_Click()
MsgBox zhuanhuan(Text1)
End Sub

Function zhuanhuan(x As Variant) As String

t = Split(x, ".")
For j = 0 To UBound(t)
If j = 0 Then
If Len(t(j)) Mod 4 <> 0 Then
a = Len(t(j)) \ 4
temp = temp & shuzi(Mid(x, 1, Len(t(j)) Mod 4), Len(t(j)) Mod 4, 0)
temp = temp & danwei(a + 1)
End If

For k = (Len(t(j)) Mod 4) + 1 To Len(t(j)) Step 4
xx = Mid(x, k, 488)
temp = temp & shuzi(xx, 4, 0)
temp = temp & danwei(a)
a = a - 1
Next
Else
temp = temp & shuzi(t(j), Len(t(j)), 1)
End If
Next
zhuanhuan = temp
End Function
Function shuzi(z As Variant, ws As Integer, h As Integer)

For i = 1 To ws

Select Case Val(Mid(z, i, 1))
Case 1
te = "壹"
Case 2
te = "贰"
Case 3
te = "叁"
Case 4
te = "肆"
Case 5
te = "伍"
Case 6
te = "陆"
Case 7
te = "柒"
Case 8
te = "捌"
Case 9
te = "玖"
Case 0
te = "零"
End Select
If (te = "零" Or i = ws) And h = 0 Then
shuzi = shuzi & te
Else
If h = 0 Then
If ws - i = 3 Then
shuzi = shuzi & te & "仟"
ElseIf ws - i = 2 Then
shuzi = shuzi & te & "佰"
ElseIf ws - i = 1 Then
shuzi = shuzi & te & "拾"
End If
Else
shuzi = shuzi & te & danwei(i - 2)
End If
End If
Next
End Function

Function danwei(y)
Select Case Val(y)
Case Is = 1
danwei = "元"
Case Is = 2
danwei = "万"
Case Is = 3
danwei = "亿"
Case Is = 4
danwei = "万亿"
Case Is = 5
danwei = "万万亿"
Case Is = 6
danwei = "万亿亿"
Case Is = 7
danwei = "万万亿亿"
Case Is = 8
danwei = "万亿亿亿"
Case Is = -1
danwei = "角"
Case Is = 0
danwei = "分"

End Select
End Function
第2个回答  2012-10-25
网上有现成的代码,百度一定可以轻易找到
第3个回答  2012-10-25
猴急猴急

用VB,通过一个命令按钮,将阿拉伯数字金额转化成汉字大写金额~~求大神...
Private Sub Command3_Click()Dim i As Integer, k As Integer, l As Integer, m As Integer, tmp As String, s1 As String, s2 As String, s3 As String, s4 As String tmp = Format(Trim(Text1.Text), "0.00")l = InStr(1, tmp, ".")k = Len(tmp)For i = 1 To k ' ...

请问将金额阿拉伯数字转换为大写汉字vb代码咋写啊例如:1234.40 转化...
如果是在excel中直接选格式——单元格--数字里选“特殊”--中文(中国)选中中文大写数字。就会自动将你的阿拉伯数字转换成大写的 如果是在WORD中选中要转换的阿拉伯数字点插入——数字---选择数字类型就行了。

用vb表达式产生“a”~“n"范围内的一个字母,并转换为大写字母
英文字母在ASCII编码表是连续的,它们的ASCII十进制码值:'a'~'z'是97~122,'A'~'Z'是65~90;因此大小写字母相差32。字符、整数它们之间是可以进行运算的,对于字符是它们的ASCII值。C代码实现:int result = rand() % ('n' - 'a' + 1) \/\/返回'a'~'n'区间内的编码值。rand函数的功能...

用vb 编写一个数字输入的键盘,可以输入数字小数点。。。先谢谢各位大虾...
昏暗的?R = InputBox(“请输入:”)如果R像“[A-Z]”,然后 打印“大写!”elseif的?喜欢“[A-Z]”,然后 打印“小写!”“[0-9]”,然后elseif的?打印“数字!”其他 “其他打印!”结束如果

...个字母到文本框1中,通过单击命令按钮将其中的大写字母转换成小写字母...
首先界面(随便弄的)其次,button1的代码:Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click TextBox1.Text = TextBox1.Text.ToUpper End SubEnd Class好,完成,运行测试

EXCEL中count和通用符号的应用
在工作表标签处按住CTRL键不放一一点击你想要设置公式的工作表,然后在你想要的位置设置公式(只在一份工作表中设置公式即可)

速达合计大写怎么设置不了
确认输入金额正确。在速达合计中,大写金额是根据输入的数字金额自动生成的,如果输入的金额不正确,大写金额也会出现错误。检查软件设置。有些速达合计软件可能需要在设置中开启大写金额功能才能正常使用。可以在软件设置中查找相关选项并进行设置。更新软件版本。如果你使用的是较老的速达合计版本,可能会存在...

智能ABC怎么打快
小提示:如果在智能ABC输入法中输入大写英文,则按键盘caps lock按钮然后直接输入,同样不必切换出智能ABC输入法(这个地球人都知道吧,呵呵)。(三)“v”+数字8。按字母 v+数字1~9可以分别显示电脑GB-2312 字符集 1~9 区的各种符号。我个人认为其中比较使用的只有v+数字8,可以输入上面有拼音声调的字母。有以下这些...

求一招好用的电脑技术
首先需要在桌面的空白处单击鼠标右键,并且新建立一个“快捷方式”,在弹出的创建快捷方式对话窗口中,在“命令行”中输入“C:windowsRUNDLL32.EXE user,ExitWindows”,然后单击“下一步”按钮,给该快捷方式命名为“一键关机”,这时系统的桌面上就会出现刚才建立的快捷方式了,打开该快捷方式的属性窗口,进入“快捷方式”页...

md5 算法程序+详细注释,高分求教!
一、综述 MD5的全称是message-digest algorithm 5(信息-摘要算法),在90年代初由mit laboratory for computer science和rsa data security inc的ronald l. rivest开发出来,经md2、md3和md4发展而来。它的作用是让大容量信息在用数字签名软件签署私人密匙前被"压缩"成一种保密的格式(就是把一 个任意长度的字节串...

相似回答