注册 登录
编程论坛 ASP技术论坛

所有值保留两位小数,并返回有人民币符号

天涯听雨 发布于 2010-10-10 17:18, 928 次点击
很久不来论坛了,今天来分享两个ASP函数


'=======================================================================================
'当数值为大于0小于1时,前台显示需处理进行加 "0"
'所有值保留两位小数
Function GetDec(byval Decimal)   
    if IsNull(Decimal) or Not isNumeric(Decimal) then
       GetDec=""
       Exit Function
    end if
    Decimal=FormatCurrency(Decimal)
    Decimal=Replace(Decimal,"¥","")
   
    if Cdbl(Decimal)>=0 and Cdbl(Decimal)<1 then
       Decimal="0"&Decimal&""
    end if
    if Cdbl(Decimal)<0 and Cdbl(Decimal)>-1 then
       Decimal=Replace(Decimal,"-","")
       Decimal="-0"&Decimal&""
    end if
    GetDec=Decimal
End Function

'=======================================================================================
'数值返回货币格式
Function GetMoney(byval Decimal)
    GetMoney="¥"&GetDec(Decimal)
End Function
2 回复
#2
gupiao1752010-10-11 22:20
路过,支持!
#3
gupiao1752010-10-11 22:22
楼主现在在做什么编程语言啊,楼主ASP挺厉害的,我还从你那学过几招!
1