当前位置: 编程技术>.net/c#/asp.net
vb.net实现数据转换为复数 金额转换成大写的代码
来源: 互联网 发布时间:2014-08-30
本文导语: 代码1: 代码示例: ''' ''' 将数据转换为Double数字 ''' ''' ''' ''' Public Shared Function todbl(ByVal Obj As Object) As Double If Obj Is DBNull.Value Then Return 0 ElseIf IsNumeric(Obj) = False Then Return 0 Else Return Obj End If End Function 代码2: ...
代码1:
代码示例:
'''
''' 将数据转换为Double数字
'''
'''
'''
'''
Public Shared Function todbl(ByVal Obj As Object) As Double
If Obj Is DBNull.Value Then
Return 0
ElseIf IsNumeric(Obj) = False Then
Return 0
Else
Return Obj
End If
End Function
''' 将数据转换为Double数字
'''
'''
'''
'''
Public Shared Function todbl(ByVal Obj As Object) As Double
If Obj Is DBNull.Value Then
Return 0
ElseIf IsNumeric(Obj) = False Then
Return 0
Else
Return Obj
End If
End Function
代码2:
代码示例:
'''
''' 将金额转换成大写
'''
''' 金额
'''
'''
Public Shared Function UpperMoney(ByVal Money As String) As String
Money = todbl(Money).ToString("0.00")
Dim strFuShu As String = IIf(Money.StartsWith("-"), "负", "")
Money = Money.Replace("-", "").Replace(".", "")
Dim Number As String = "零壹贰叁肆伍陆柒捌玖"
Dim Unit As String = "分角元拾佰仟万拾佰仟亿拾佰仟万"
Dim str As String
For i As Integer = 0 To Money.Length - 1
Dim c As String = Money.Chars(i)
Dim Index As Integer = Money.Length - 1 - i
str &= Number(c) & Unit(Index)
Next
str = strFuShu & str & "整"
Return str
End Function
''' 将金额转换成大写
'''
''' 金额
'''
'''
Public Shared Function UpperMoney(ByVal Money As String) As String
Money = todbl(Money).ToString("0.00")
Dim strFuShu As String = IIf(Money.StartsWith("-"), "负", "")
Money = Money.Replace("-", "").Replace(".", "")
Dim Number As String = "零壹贰叁肆伍陆柒捌玖"
Dim Unit As String = "分角元拾佰仟万拾佰仟亿拾佰仟万"
Dim str As String
For i As Integer = 0 To Money.Length - 1
Dim c As String = Money.Chars(i)
Dim Index As Integer = Money.Length - 1 - i
str &= Number(c) & Unit(Index)
Next
str = strFuShu & str & "整"
Return str
End Function