vb的:
Function Convertje(Value)
dim i,j,result
snumber="壹贰叁肆伍陆柒捌玖"
qian="分角元拾佰仟万拾佰仟亿拾佰仟"
Result=""
j=1
tt=""
Value=Cstr(FormatNumber(Value,2))
Value=Replace(Value,",","")
If Value="0.00" Then
   Convertje="零元整"
Else
For i=len(value) to 1 step -1
    temp=mid(value,i,1)
    If Temp="." Then
       If Result="" Then 
          tt="元整"
       Else
          tt=""
       End If
    ElseIf Temp="0" Then
       tt=""
    Else
       tt=mid(snumber,cint(temp),1)&mid(qian,j,1)
    End If
    Result=tt&Result
    If Temp<>"." Then  j=j+1
Next
Convertje=Result
End If
End Function

解决方案 »

  1.   

    你自己去改成jscript or vbscriptint EditMoneyToChn( char * in, char * out )
    {
        int     ret, decimal;
        char    s1[1024], s2[ 10 ];
        int     i, j, k, l, n, len1;
        char  * p_dot;    char    chn_digit[11][3] = { "零", "壹", "贰", "叁", "肆", "伍",
     "陆", "柒", "捌", "玖" };
        char    chn_unit1[4][3] = { "", "拾", "佰", "仟" };
        char    chn_unit2[3][5] = { "万", "亿", "万亿" };    if ( in == NULL )
           return (0);
        if ( strlen( in ) == 0 )
           return (0);
        memset(s1,0x00,sizeof(s1));
        strcpy( s1, in );
        p_dot = strchr( s1, '.' );
        if ( p_dot == NULL )
            s2[0] = 0x0;
        else
        {
            memset(s2,0x00,sizeof(s2));
            strcpy( s2, p_dot + 1 );
            *p_dot = 0x0;
        }    /*
         * 转换为中文
         */
        out[0] = 0x0;
        len1 = strlen( s1 );
        n = ( len1 - 1 ) / 4 + 1;
        l = 0;
        for ( i = 0; i < n; i++ )
        {
            if ( i == 0 )
                k = len1 - 4 * ( n - 1 );
              else
                k = 4;
            for ( j = 0; j < k; j++, l++ )
            {
                if ( s1[ l ] == '0' &&
                     ( ( j + 1 < k && s1[ l+1 ] == '0' ) ||
                       j + 1 == k ) )
                    continue;
                if ( k - j != 2 || s1[l] != '1' || strlen( out ) > 0 )
                    strcat( out, chn_digit[ s1[ l ] - '0' ] );
                if ( s1[ l ] != '0' )
                    strcat( out, chn_unit1[ k - j - 1 ] );
            }
            if ( i < n - 1 && memcmp( s1 + 4*i, "0000", k ) != 0 )
                strcat( out, chn_unit2[ n - i - 2 ] );
        }
        if ( strlen( out ) != 0 )
            strcat( out, "元" );
        decimal = 2;
        if ( atoi( s2 ) == 0 )
            strcat( out, "整" );
        else
        {
         if ( len1 > 1 && s1[ len1 - 1 ] == '0' )
                strcat( out, "零" );
            if ( s2[0] != '0' )
            {
                strcat( out, chn_digit[ s2[0] - '0' ] );
                strcat( out, "角" );
            }
            if ( s2[1] != '0' )        {
                strcat( out, chn_digit[ s2[1] - '0' ] );
                strcat( out, "分" );        }
        }    return(0);
    }
      

  2.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>转换大写金额</title>
    <STYLE type=text/css>
    INPUT { BORDER-RIGHT: #c0d3dc 1px solid; BORDER-TOP: #c0d3dc 1px solid; BORDER-LEFT: #c0d3dc 1px solid; BORDER-BOTTOM: #c0d3dc 1px solid; font-family: verdana; HEIGHT: 19px}
    BODY {font-family:arial,helvetica,Tahoma; font-size: 9pt; color:'094A82'}
    </STYLE>
    <bgsound id=bgsoundone src="" loop=1>
    </head>
    <body>
    <SCRIPT LANGUAGE="VBScript">            
    dim hj,hji
    sub document_onkeypress()
        if window.event.srcelement.id="num" and window.event.keycode="13" then
       call retu_cn()
    end if
    end sub
    sub window_onload()
    document.fmSubmit.t1.focus()
    end sub
    SUB retu_cn()
    dim n,m_hj,s,ch,ch2,ch3,num
    num=Replace(trim(document.fmSubmit.t1.value),",","",1,-1,1)
    if num="" then
       MsgBox "您还没有输入金额!"
       document.fmSubmit.t1.focus()
       exit sub
    End If
    if IsNumeric(num)=False then
       MsgBox "您输入的不是金额!"
       document.fmSubmit.t1.focus()
       exit sub
    End If
    n=FormatNumber(num,2,-1)
    num=n
    n=Replace(n,",","",1,-1,1)
    If len(n)>15 Then
       MsgBox "金额必须小于千亿!"
       document.fmSubmit.t1.focus()
       exit sub
    End If
    hj=space(0)
    s="840"
    ch="壹贰叁肆伍陆柒捌玖"
    ch2="仟佰拾  "
    ch3="亿万元"
    for x=1 to 3
        m=cstr(int(n/10^FormatNumber(mid(s,x,1),0,-1)))
        m=space(4-len(m))+m
        m_hj=space(0)
        if m<>"   0" then
           for y=1 to 4
               if mid(m,y,1)<>space(1) and mid(m,y,1)<>"0" then
                  m_hj=trim(m_hj+mid(ch,FormatNumber(mid(m,y,1),0,-1),1)+mid(ch2,y,1))
               else
                  if mid(m,y,1)=space(1) or mid(m,y,1)="0" then
                     m_hj=m_hj
                     if right(m_hj,1)="零" then
                        m_hj=m_hj+space(0)
                     else
                        m_hj=m_hj+"零"
                     end if
                  else
                     m_hj=m_hj
                  end if
               end if   
           next
           if right(m_hj,1)="零" then
              m_hj=mid(m_hj,1,len(m_hj)-1)+mid(ch3,x,1)
              if x=3 then
                 m_hj=m_hj+space(0)
              else
                 m_hj=m_hj+"零"
              end if
           else
              m_hj=m_hj+mid(ch3,x,1)
           end if 
           if right(hj,1)="零" and mid(m_hj,1,1)="零" then
              hj=hj+mid(m_hj,2,len(m_hj)-1)
           else
              hj=hj+m_hj
           end if
        else 
           if x=3 then
              if right(hj,1)="零" then
                 if trim(hj)="零" then
                    hj=hj+space(0)
                 else
                    hj=mid(hj,1,len(hj)-1)+"元"
                 end if
              else
                 if trim(hj)="零" then
                    hj=hj+space(0)
                 else
                    hj=hj+"元"
                 end if
              end if
           else
              if right(hj,1)="零" then
                 hj=hj+space(0)
              else
                 hj=hj+"零"
              end if   
           end if   
        end if
        if n-int(n)=0 then
           n=n-int(FormatNumber(m,0,-1))*10^int(FormatNumber(mid(s,x,1),0,-1))
        else
           tt=FormatNumber("0."+mid(cstr(n),Instr(1,n,".")+1,2),2)
           n=int(n) 
           n=n-int(FormatNumber(m,0,-1))*10^int(FormatNumber(mid(s,x,1),0,-1))
           n=n+tt
        end if
    next
      m=mid(cstr(n),2,2)
      if trim(len(m))<>2 then
         m=m+"0"
      end if
      if n*100=0 then
         if left(hj,1)="零" then
            if right(hj,1)="零" then
               hj=hj+"元整"
            else
               hj=mid(hj,2,len(hj)-1)+"整"
            end if
         else
            if right(hj,1)="零" then
               hj=mid(hj,1,len(hj)-1)+"整"
            else
               hj=hj+"整"
            end if
         end if
      else
         if right(hj,1)="零" then
            hj=mid(hj,1,len(hj)-1)
         else
            hj=hj
         end if
         if mid(m,1,1)="0" or mid(m,1,1)=space(1) then
            hj=hj+"零"
         else
            hj=hj+mid(ch,FormatNumber(mid(m,1,1),0,-1),1)+"角"
         end if
         if mid(hj,1,1)="零" then
            hj=mid(hj,2,len(hj)-1)
         else
            hj=hj
         end if
         if mid(m,2,1)="0" then
            hj=hj+"整"
         else
            hj=hj+mid(ch,FormatNumber(mid(m,2,1),0,-1),1)+"分"
         end if   
      end if
    if num=".00" then
       document.fmSubmit.t1.value="0.00"
    else
       document.fmSubmit.t1.value=num
    end if   
    document.fmSubmit.t2.value=""
    hji=1
    call read()
    End Sub
    SUB read()
        MyVar=mid(hj,hji,1)
        document.fmSubmit.t2.value=document.fmSubmit.t2.value+MyVar
        Select Case MyVar
               Case "零"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/0.wav"
               Case "壹"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/1.wav"
               Case "贰"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/2.wav"
               Case "叁"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/3.wav"
               Case "肆"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/4.wav"
               Case "伍"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/5.wav"
               Case "陆"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/6.wav"
               Case "柒"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/7.wav"
               Case "捌"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/8.wav"
               Case "玖"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/9.wav"
               Case "拾"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/10.wav"
               Case "佰"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/b.wav"
               Case "仟"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/q.wav"
               Case "万"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/w.wav"
               Case "亿"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/y.wav"
               Case "元"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/yuan.wav"
               Case "分"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/fen.wav"
               Case "角"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/jiao.wav"
               Case "整"     document.all("bgsoundone").src="http://go.163.com/yjsj/wav/z.wav"
               Case else     hji=0
                             document.all("bgsoundone").src=""
                             exit sub
        End Select
        hji=hji+1
       setTimeout "read",400
    End Sub
    </script>
    最完整、最标准的大写金额转换程序,特别是“零”和“整”的转换,最大金额可到仟亿。     
    <br>
    并加入了朗读功能,所以说是最完美的大写金额转换程序!
    <br>
    如有BUG请高手指教!!!
    <form id=fmSubmit name=fmSubmit method="POST">
      <p>请输入金额:<input type="text" name="T1" size="20" id="num">  <input type="button" onclick=retu_cn() value="转换大写金额" name="B1"></p>
      <br>  大写金额:<input type="text" name="T2" size="55" readonly>
    </form>
    </body>
    </html>