请问怎样把阿拉伯数字变成汉字?
vb吧
全部回复
仅看楼主
level 1
结奈 楼主
做报表时要打印最后的金额,用汉字。我想的办法是拿那个数除以1000,100,10……这样的,依商把汉字一个一个替进去。但感觉不太方便,不知道大家都是怎么做的?
2006年08月23日 13点08分 1
level 7
给你一个转换过程,详情请查看:http://post.baidu.com/f?kz=123714281Private Function CChinese(StrEng As String) As String If Not IsNumeric(StrEng) Or StrEng Like "*.*" Or StrEng Like "*-*" Then If Trim(StrEng) <> "" Then MsgBox "无效的数字" CChinese = "": Exit Function End If Dim intLen As Integer, intCounter As Integer Dim strCh As String, strTempCh As String Dim strSeqCh1 As String, strSeqCh2 As String Dim strEng2Ch As String strEng2Ch = "零壹贰叁肆伍陆柒捌玖" strSeqCh1 = " 拾佰仟 拾佰仟 拾佰仟 拾佰仟" strSeqCh2 = " 万亿兆" StrEng = CStr(CDec(StrEng)) intLen = Len(StrEng) For intCounter = 1 To intLen strTempCh = Mid(strEng2Ch, Val(Mid(StrEng, intCounter, 1)) + 1, 1) If strTempCh = "零" And intLen <> 1 Then If Mid(StrEng, intCounter + 1, 1) = "0" Or (intLen - intCounter + 1) Mod 4 = 1 Then strTempCh = "" End If Else strTempCh = strTempCh & Trim(Mid(strSeqCh1, intLen - intCounter + 1, 1)) End If If (intLen - intCounter + 1) Mod 4 = 1 Then strTempCh = strTempCh & Mid(strSeqCh2, (intLen - intCounter + 1) \ 4 + 1, 1) If intCounter > 3 Then If Mid(StrEng, intCounter - 3, 4) = "0000" Then strTempCh = Left(strTempCh, Len(strTempCh) - 1) End If End If strCh = strCh & Trim(strTempCh) Next CChinese = strCh End Function
2006年08月23日 14点08分 2
level 0
很谢谢楼上的前辈,不过我完全看不懂……因为是临时需要编一个软件才开始看VB,语法知识很少……
2006年08月23日 14点08分 3
level 1
结奈 楼主
应该不会很麻烦,因为我要打印在票据上,而票据上已经有个,十,百这些数字了,只要提取出每个位的数字……不知道哪位可以帮忙?
2006年08月23日 15点08分 4
level 13
http://post.baidu.com/f?ct=335675392&tn=baiduPostBrowser&sc=1040215256&z=123111014&pn=0&rn=50&lm=0&word=vb#1040215256
2006年08月24日 20点08分 5
1