服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - ASP.NET教程 - asp.net(vb)实现金额转换成大写的函数

asp.net(vb)实现金额转换成大写的函数

2019-09-20 14:03asp.net开发网 ASP.NET教程

asp.net(vb)实现金额转换成大写的函数代码,需要的朋友可以参考下。

代码如下:


''' <summary> 
''' 将数据转换为Double数字 
''' </summary> 
''' <param name="Obj"></param> 
''' <returns></returns> 
''' <remarks></remarks> 
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 

 

复制代码代码如下:


''' <summary> 
''' 将金额转换成大写 
''' </summary> 
''' <param name="Money">金额</param> 
''' <returns></returns> 
''' <remarks></remarks> 
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 

延伸 · 阅读

精彩推荐