zoukankan      html  css  js  c++  java
  • delphi小写金额转大写的函数《转》

    function NumToChar(const n: Real): string; //可以到万亿,并且可以随便扩大范围 
    const cNum: WideString = '零壹贰叁肆伍陆柒捌玖--万仟佰拾亿仟佰拾万仟佰拾元角分'; 
    cCha:array[0..1, 0..12]of string = (( '零元','零拾','零佰','零仟','零万','零亿','亿万','零零零','零零','零万','零亿','亿万','零元'), ( '','','','','','亿','亿','','','','亿','亿','')); 
    
    var i : Integer; 
    sNum,sTemp : WideString; 
    begin 
    result :=''; 
    sNum := format('%15d',[round(n * 100)]); 
    for i := 0 to 14 do 
    begin 
    stemp := copy(snum,i+1,1); 
    if stemp=' ' then continue 
    else result := result + cNum[strtoint(stemp)+1] + cNum[i+13]; 
    end; 
    for i:= 0 to 12 do 
    Result := StringReplace(Result, cCha[0,i], cCha[1,i], [rfReplaceAll]); 
    if pos('零分',result)=0 then 
    Result := StringReplace(Result, '零角', '', [rfReplaceAll]) 
    else Result := StringReplace(Result, '零角','', [rfReplaceAll]); 
    
    Result := StringReplace(Result, '零分','', [rfReplaceAll]); 
    end; 
    
    function Changdx2(mmje: Double): String; 
    const s1: String = '零壹贰叁肆伍陆柒捌玖'; 
    s2: String = '分角元拾佰仟万拾佰仟亿拾佰仟万'; 
    function StrTran(const S, S1, S2: String): String; 
    begin 
    Result := StringReplace(S, S1, S2, [rfReplaceAll]); 
    end; 
    var s, dx: String; 
    i, Len: Integer; 
    begin 
    if mmje < 0 then 
    begin 
    dx := ''; 
    mmje := -mmje; 
    end; 
    s := Format('%.0f', [mmje*100]); 
    Len := Length(s); 
    for i := 1 to Len do 
    dx := dx + Copy(s1, (Ord(s[i]) - Ord('0'))*2 + 1, 2) + Copy(s2, (Len - i)*2 + 1, 2); 
    dx := StrTran(StrTran(StrTran(StrTran(StrTran(dx, '零仟', ''), '零佰', ''), '零拾', ''), '零角', ''), '零分', ''); dx := StrTran(StrTran(StrTran(StrTran(StrTran(dx, '零零', ''), '零零', ''), '零亿', '亿'), '零万', ''), '零元', ''); if dx = '' then 
    Result := '零元整' 
    else Result := StrTran(StrTran(dx, '亿万', '亿零'), '零整', ''); 
    end;
  • 相关阅读:
    Redpine的Lite-Fi解决方案获Wi-Fi CERTIFIED认证
    植物园偶遇一直喵
    美食篇
    端午节路过南站
    黄山云海
    一品黄山 天高云淡
    黄山的日出日落
    宏村,寻找你的前世今生
    git把本地文件上传到github上的步骤
    一张照片一个故事
  • 原文地址:https://www.cnblogs.com/LceMeaning/p/3365394.html
Copyright © 2011-2022 走看看