日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

delphi 金额大小写转换函数

發布時間:2023/12/13 综合教程 23 生活家
生活随笔 收集整理的這篇文章主要介紹了 delphi 金额大小写转换函数 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
{*------------------------------------------------
  金額大小寫轉換函數
  @author  王云盼
  @version V1506.01
 在delphi7測試OK -------------------------------------------------} unit UnTranRMB; //主要是考慮數字的小數部分,和大寫金額的零 interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; function TranRMB(const Value: string): string; /// const 和 var 常量 變量 數字金額轉換成大寫金額 function TranNum(M: string):string; /// 大寫金額轉換成數字金額 implementation {*------------------------------------------------ 判斷是否有小數點, 切給出小數點出現的位置 和小數點的數目 @param S 字符串 @param Pos 小數點位置 @param Number 小數點個數 @return Boolean -------------------------------------------------} function IsPoint(S: string; var Pos: Integer; var Number: integer): Boolean; var I: integer; begin Result := False; Number := 0; for I := 1 to length(S) do begin if S[I] = '.' then begin Pos := I; Number := Number + 1; Result := True; end; end; end; {*------------------------------------------------ 檢測字符串是否合理,若小數點超過1個或者字符串開頭是0 @param Value @return Boolean -------------------------------------------------} function ChickStr(Value: double): Boolean; var J, K : Integer; begin Result := False; if Value <= 0 then Result := True; if IsPoint(floatToStr(Value), J, K) = True then if K >= 2 then Result := True; end; {*------------------------------------------------ 轉換小寫函數 @param @return -------------------------------------------------} function TranNum(M: string):string; var N: Integer; S: string; begin S := '.00'; if Length(M) = 1 then Result := '¥' + M + S else Result := '¥' + M ; end; {*------------------------------------------------ 數字金額轉換成大寫金額 @param @return -------------------------------------------------} function TranRMB(const Value: string): string; var I, J, K, L, V, Pos, LZPart, LXPart : integer; S1: string; IsZero: Boolean; begin if ((Value[1]='0') and (Value[2]<>'.')) or (Value[1]='.') then /// 第一位不能為小數點 begin ShowMessage('不符合要求'); exit; end; //if ChickStr(FloatToStr(S1)) = True then exit; /// 判斷是否可以轉換 L := length(Value); /// 初始化轉換的數字長度 Result := '人民幣'; /// 初始化返回值 /// 有小數情況 if IsPoint(Value, Pos, J) = True then begin LXPart := L - Pos; /// 小數部分長度 LZPart := L - LXPart - 1; /// 整數部分長度 if StrToFloat(Value) = 0 then begin Result :=Result + '零元整'; exit; end; for J := 1 to LZPart do /// 當前位置 begin K := StrToInt(Value[J]); /// 當前位置的內容 V := LZPart - J + 1; /// 當前位置的權 case K of /// 獲取當前位置內容的大寫值 1: S1 := '壹'; 2: S1 := '貳'; 3: S1 := '叁'; 4: S1 := '肆'; 5: S1 := '伍'; 6: S1 := '陸'; 7: S1 := '柒'; 8: S1 := '捌'; 9: S1 := '玖'; 0: begin /// 有0的情況 S1 := '零'; if J < LZPart then /// 如果不是最后一位,則判斷低位是否也有0,有0不顯示 begin if (Value[J+1] = '') or (Value[J+1] = '0') then S1 := ''; end; if J = LZPart then /// 0在最后一位也不顯示 S1 := ''; end; end; case V of /// 權的情況 1:begin if K = 0 then begin if StrToFloat(Value) < 1 then begin S1 := ''; Result := Result + S1; end else begin S1 := ''; Result := Result + S1 + '元' ; end; end else Result := Result + S1 + '元'; end; 2:begin if K = 0 then Result := Result + S1 else Result := Result + S1 + '拾'; end; 3:begin if K = 0 then Result := Result + S1 else Result := Result + S1 + '百' ; end; 4:begin if K = 0 then Result := Result + S1 else Result := Result + S1 + '仟' ; end; 5:begin if K = 0 then begin S1 := ''; Result := Result + S1 + '萬' ; end else Result := Result + S1 + '萬'; end; 6:begin if K = 0 then Result := Result + S1 else Result := Result + S1 + '拾'; end; 7:begin if K = 0 then Result := Result + S1 else Result := Result + S1 + '百'; end; 8:begin if K = 0 then Result := Result + S1 else Result := Result + S1 + '仟'; end; 9:begin if K = 0 then begin S1 := ''; Result := Result + S1 + '萬' ; end else Result := Result + S1 + '億'; end; 10:begin if K = 0 then Result := Result + S1 else Result := Result + S1 + '拾'; end; 11:begin if K = 0 then Result := Result + S1 else Result := Result + S1 + '百'; end; 12:begin if K = 0 then Result := Result + S1 else Result := Result + S1 + '仟'; end; 13:begin if K = 0 then Result := Result + S1 else Result := Result + S1 + '萬'; end; 14:begin if K = 0 then Result := Result + S1 else Result := Result + S1 + '兆'; end; end; end; for I := 1 to LXPart do begin V := StrToInt(Value[I+Pos]) ; case V of 1: S1 := '壹'; 2: S1 := '貳'; 3: S1 := '叁'; 4: S1 := '肆'; 5: S1 := '伍'; 6: S1 := '陸'; 7: S1 := '柒'; 8: S1 := '捌'; 9: S1 := '玖'; 0: begin S1 := '零'; if I < L then /// 如果不是最后一位 begin if (Value[I+Pos+1] = '') or (Value[I+Pos+1] = '0') then begin IsZero := True; S1 := ''; end; end; if I = L then S1 := ''; end; end; case I of 1: begin if V = 0 then begin Result := Result + S1 ; end else Result := Result + S1 + '角'; end; 2: begin if V = 0 then begin Result := Result + S1 ; end else Result := Result + S1 + '分'; end; 3: begin if V = 0 then begin Result := Result + S1 ; end else Result := Result + S1 + '厘'; end; 4: begin if V = 0 then begin Result := Result + S1 ; end else Result := Result + S1 + '毫'; end; end; end; if S1 = '' then Result := Result + '整'; end /// 不是小數情況 else begin for I := 1 to L do /// 當前位的位置 begin V := StrToInt(Value[I]) ; /// 當前位的內容 K := L - I + 1; /// 當前位的權 case V of 1: S1 := '壹'; 2: S1 := '貳'; 3: S1 := '叁'; 4: S1 := '肆'; 5: S1 := '伍'; 6: S1 := '陸'; 7: S1 := '柒'; 8: S1 := '捌'; 9: S1 := '玖'; 0: begin S1 := '零'; if I < L then /// 如果不是最后一位 begin /// 判斷下一位是不是0,低位0不顯示 if (Value[i+1] = '') or (Value[i+1] = '0') then S1 := ''; end; if I = L then S1 := ''; end; end; case K of 1:begin if V = 0 then /// 當有零的情況 Result := Result + S1 + '元整' else Result := Result + S1 + '元整'; end; 2:begin if V = 0 then Result := Result + S1 else Result := Result + S1 + '拾'; end; 3:begin if V = 0 then Result := Result + S1 else Result := Result + S1 + '百' ; end; 4:begin if V = 0 then Result := Result + S1 else Result := Result + S1 + '仟' ; end; 5:begin if V = 0 then begin S1 := ''; Result := Result + S1 + '萬' ; end else Result := Result + S1 + '萬'; end; 6:begin if V = 0 then Result := Result + S1 else Result := Result + S1 + '拾'; end; 7:begin if V = 0 then Result := Result + S1 else Result := Result + S1 + '百'; end; 8:begin if V = 0 then Result := Result + S1 else Result := Result + S1 + '仟'; end; 9:begin if V = 0 then begin S1 := ''; Result := Result + S1 + '億' ; end else Result := Result + S1 + '億'; end; 10:begin if V = 0 then Result := Result + S1 else Result := Result + S1 + '拾'; end; 11:begin if V = 0 then Result := Result + S1 else Result := Result + S1 + '百'; end; 12:begin if V = 0 then Result := Result + S1 else Result := Result + S1 + '仟'; end; 13:begin if V = 0 then Result := Result + S1 else Result := Result + S1 + '萬'; end; 14:begin if V = 0 then Result := Result + S1 else Result := Result + S1 + '兆'; end; end; end; end; end; end.

總結

以上是生活随笔為你收集整理的delphi 金额大小写转换函数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。