将阿拉伯数字转成中文字

王朝vb·作者佚名  2006-01-08
宽屏版  字体: |||超大  

Private 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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
>>返回首页<<
© 2005- 王朝网络 版权所有