欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2024-03-07 19:27:27
复制代码 代码如下: ''' ''' 将数据转换为double数字 ''' '''
复制代码 代码如下:

''' <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