本文主要是介绍钱小写转大写 VB,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Function DaXie(ByVal Num As String) As String 'If IsNumeric(Num) = False Then
DaXie = ""
Exit Function
End If
Dim Place As String = "分角元拾佰仟万拾佰仟亿拾佰仟万"
Dim Dn As String = "壹贰叁肆伍陆柒捌玖"
Dim D1 As String = "整零元零零零万零零零亿零零零万"
Dim FuHao As String
If Num < 0 Then FuHao = "(负)"
Num = Format(Math.Abs(CDbl(Num)), "0.00") * 100 'Replace(CStr(Format(CDbl(Num), "0.00")), ".", "")
If Num > 999999999999999.0 Then
DaXie = ""
Exit Function
End If
If Num = 0 Then
DaXie = "零元零分"
Exit Function
End If
Dim NumA As String
NumA = Trim(Num)
Dim NumLen As Integer = Len(NumA)
Dim j As Integer
Dim NumC As String
For j = NumLen To 1 Step -1 ' 数字转换过程
Dim temp As Double = Val(Mid(NumA, NumLen - j + 1, 1))
If temp <> 0 Then ' 非零数字转换
NumC = NumC & Mid(Dn, temp, 1) & Mid(Place, j, 1)
Else ' 数字零的转换
If Right(NumC, 1) <> "零" Then
NumC = NumC & Mid(D1, j, 1)
Else
Select Case j ' 特殊数位转换
Case 1
NumC = Left(NumC, Len(NumC) - 1) & Mid(D1, j, 1)
Case 3, 11
NumC = Left(NumC, Len(NumC) - 1) & Mid(D1, j, 1) & "零"
Case 7
If Mid(NumC, Len(NumC) - 1, 1) <> "亿" Then
NumC = Left(NumC, Len(NumC) - 1) & Mid(D1, j, 1) & "零"
End If
Case Else
End Select
End If
End If
Next
DaXie = FuHao & Trim(NumC)
End Function
这篇关于钱小写转大写 VB的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!