程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> ASP.NET >> ASP.NET基礎 >> asp.net(vb)實現金額轉換成大寫的函數

asp.net(vb)實現金額轉換成大寫的函數

編輯:ASP.NET基礎
復制代碼 代碼如下:
''' <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
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved