数字小写到英文大写的转换

数字小写到英文大写的转换
日期:2004年8月13日 作者:gaojian 人气: 7124  今日:6     [大 中 小]
<%

FUNCTION convertsz(sz)

'PARAMETERS sz

'PRIVATE xs,sz1,sz2,sz3

        IF sz > 1000000000 then '超过处理范围提示
        
           convertsz="Number is too big" '数字大于10亿,超过处理范围!
        exit FUNCTION
        END IF

sz=INT(sz*100+0.5)/100   ' 小数超过两位四舍五入

xs=((sz-int(sz))*100) MOD 100   ' 取小数点后两位有效数字

IF xs>0 then

    'cha=" AND"&conv3(xs)&" CENTS"   ' 转换小数
     cha=" AND "&xs&" CENTS"

ELSE

    cha=""

END IF

sz1=INT((sz MOD 1000))       ' sz1为百、十、个3位数字

sz=INT(sz/1000)             ' sz为千位以上数字(含千位)

cha=conv3(sz1)&cha          ' 转换(sz1)

        IF sz>0 then
        
            sz2=(sz MOD 1000)        ' sz2为十万、万、千3位数字
         
            sz=INT(sz/1000)         ' sz为百万位以上数字(含百万位)
        
                    IF sz2=0 then
                        
                                IF sz1=0  then         ' (sz2)如果为'0',判断在百位之前是否加'AND'
                        
                                    cha=cha
                        
                                ELSE
                        
                                    cha=" AND"&cha
                        
                                END IF
                
                    ELSE
                
                               cha=conv3(sz2)&" THOUSAND"&cha   ' 如果不为'0'转换(sz2)
                
                    END IF
        
                    IF sz>0 then
                
                        sz3=(sz MOD 1000)                                ' sz3为亿、千万、百万3位数字
                
                        cha=conv3(sz3)&" MILLION"&cha                   ' 转换(sz3)
                
                    END IF
        
        END IF

'cha="DOLLAR"&cha                    ' 在转换的结果之前加'DOLLAR'

'RETURN cha
convertsz=cha

end FUNCTION


FUNCTION conv3(je)

'PARAMETERS je

'PRIVATE jews,je1,je2,je3,tmp

IF je<=0 then

    convertsz=""
    exit FUNCTION

END IF

je1=(je MOD 10)

je=INT(je/10)

            IF je=0 then                 ' 判断数字位数(1-3)并把3位数字分别存放在je1、je2、je3中
            
                jews=1
            
            ELSE
            
                je2=(je MOD 10)
            
                je=INT(je/10)
            
                            IF je=0 then
                        
                                jews=2
                        
                            ELSE
                        
                                je3=(je MOD 10)
                        
                                jews=3
                        
                            END IF
            
            END IF

IF jews=1 then

    tmp=conv1(je1)   '如果位数为1,直接转换
    
    conv3=tmp
    
    'exit FUNCTION
    'RETURN tmp

ELSE

    IF je1+10*je2<20 then      ' 转换20以下数字

        tmp=conv1(je1+10*je2)

    ELSE                       ' 转换20-99数字

        IF je1=0 then

            tmp=conv2(je2)

        ELSE

            'tmp=conv2(je2)&" -"&conv1(je1)
            tmp=conv2(je2)&conv1(je1)


        END IF

    END IF

    IF jews=3 then     '转换百位数字

        IF je1+10*je2=0 then

            tmp=conv1(je3)&" HUNDRED"

        ELSE

            IF je1+10*je2<20 then

                tmp=conv1(je3)&" HUNDRED  AND"&tmp

            ELSE

                tmp=conv1(je3)&" HUNDRED"&tmp

            END IF

        END IF

    END IF

    conv3=tmp

END IF

end FUNCTION


FUNCTION conv2(SUM)

'PARAMETERS SUM
aaa=""
select CASE SUM

    CASE 2

        aaa=" TWENTY"

    CASE 3

        aaa=" THIRTY"

    CASE 4

        aaa=" FORTY"

    CASE 5

        aaa=" FIFTY"

    CASE 6

        aaa=" SIXTY"

    CASE 7

        aaa=" SEVENTY"

    CASE 8

        aaa=" EIGHTY"

    CASE 9

        aaa=" NINETY"

  

END select

conv2=aaa

end FUNCTION


FUNCTION conv1(SUM)

'PARAMETERS SUM
aaa=""
select CASE SUM

    CASE 1

        aaa=" ONE"

    CASE 2

        aaa=" TWO"

    CASE 3

       aaa=" THREE"

    CASE 4

       aaa=" FOUR"

    CASE 5

        aaa=" FIVE"

    CASE 6

        aaa=" SIX"

    CASE 7

        aaa=" SEVEN"

    CASE 8

        aaa=" EIGHT"

    CASE 9

        aaa=" NINE"

    CASE 10

        aaa=" TEN"

    CASE 11

        aaa=" ELEVEN"

    CASE 12

        aaa=" TWELVE"

    CASE 13

        aaa=" THIRTEEN"

    CASE SUM=14

        aaa=" FOURTEEN"

    CASE 15

        aaa=" FIFTEEN"

    CASE 16

        aaa=" SIXTEEN"

    CASE 17

        aaa=" SEVENTEEN"

    CASE 18

        aaa=" EIGHTEEN"

    CASE SUM=19

        aaa=" NINETEEN"



END select

conv1=aaa

end FUNCTION


fff=123456789.45

response.write fff&"<br>"

xx=convertsz(fff)


response.write xx

%>

(出处:devclub)

相关文章:
 
 
·将汉字转换成汉语拼音的一段代码
·利用XSLT把ADO记录集转换成XML
·使用MySql ODBC进行MYsql和MS sql7的数据转换
·GB与BIG5内码转换COM原代码
·金额阿拉伯数字转换为中文的存储过程
·asp程序和php程序转换要注意的问题
·一个非常简单的将半角"转换为中文“的函数
·货币大写转换函数的更新
·人民币小写转换为大写
·数据变换和转换注意事项(SQL)
相关软件:
 
 
·Leadbbs288 To 动网论坛V7.0转换程序
·BBS3000论坛到动网论坛转换程序
·BBSxp论坛到动网论坛转换程序
·LB5000雷傲论坛到动网论坛转换程序
·浩翔TO动网转换程序(For 0519)
·雷奥论坛转换动网论坛程序
·WDB论坛转换动网论坛程序V1.0
·神鸟公司ASP到asp.net的转换工具
 
 
 
说明:本站部分内容收集于网络,如有侵犯您的权益请来信告知,我们会第一时间进行处理,谢谢

你可能感兴趣的:(mysql,function,asp.net,asp,Parameters,XSLT)