?? commonuse.pas
字號(hào):
$A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2014
$95, $B4, $96, $A5, $96, $97, $88, $78, $78, $79, $77, $87, //2015
$95, $B4, $A5, $B4, $A5, $A6, $87, $88, $87, $78, $87, $86, //2016
$A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $87, //2017
$A5, $B4, $A6, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2018
$A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $79, $77, $87, //2019
$95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $86, //2020
$A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2021
$A5, $B4, $A5, $A5, $A6, $96, $88, $88, $88, $78, $87, $87, //2022
$A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $79, $77, $87, //2023
$95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96, //2024
$A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2025
$A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2026
$A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //2027
$95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96, //2028
$A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2029
$A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2030
$A5, $B4, $96, $A5, $96, $96, $88, $78, $78, $78, $87, $87, //2031
$95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96, //2032
$A5, $C3, $A5, $B5, $A6, $A6, $88, $88, $88, $78, $87, $86, //2033
$A5, $B3, $A5, $A5, $A6, $A6, $88, $78, $88, $78, $87, $87, //2034
$A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2035
$95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96, //2036
$A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $86, //2037
$A5, $B3, $A5, $A5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2038
$A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2039
$95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $78, $87, $96, //2040
$A5, $C3, $A5, $B5, $A5, $A6, $87, $88, $87, $78, $87, $86, //2041
$A5, $B3, $A5, $B5, $A6, $A6, $88, $88, $88, $78, $87, $87, //2042
$A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2043
$95, $B4, $A5, $B4, $A5, $A6, $97, $87, $87, $88, $87, $96, //2044
$A5, $C3, $A5, $B4, $A5, $A6, $87, $88, $87, $78, $87, $86, //2045
$A5, $B3, $A5, $B5, $A6, $A6, $87, $88, $88, $78, $87, $87, //2046
$A5, $B4, $96, $A5, $A6, $96, $88, $88, $78, $78, $87, $87, //2047
$95, $B4, $A5, $B4, $A5, $A5, $97, $87, $87, $88, $86, $96, //2048
$A4, $C3, $A5, $A5, $A5, $A6, $97, $87, $87, $78, $87, $86, //2049
$A5, $C3, $A5, $B5, $A6, $A6, $87, $88, $78, $78, $87, $87); //2050
Function SmallToBig5(Const aNumber: Double): String;
Var
i, j: Integer; //轉(zhuǎn)換出數(shù)量漢字大寫(xiě)字符串
zheng: Integer;
ch, LowerSL: String;
A: Array[1..10] Of String;
B: Array[1..13] Of String;
Begin
LowerSL := FloatToStr(aNumber);
A[1] := '壹';
A[2] := '貳';
a[3] := '叁';
a[4] := '肆';
a[5] := '伍';
a[6] := '陸';
A[7] := '柒';
A[8] := ' 捌';
A[9] := '玖';
A[10] := '拾';
b[1] := '';
b[2] := '拾';
b[3] := '佰';
B[4] := '仟';
b[5] := '萬(wàn)';
b[6] := '拾萬(wàn)';
b[7] := '佰萬(wàn)';
b[8] := '仟萬(wàn)';
b[9] := '億';
b[10] := '拾億';
b[11] := '佰億';
b[12] := '仟億';
b[13] := '';
zheng := Length(LowerSL) + 1;
i := length(IntToStr(trunc(strtofloat(LowerSL)))) + 1;
If LowerSL[1] = '.' Then
Begin
ch := ch + '零';
j := 1;
If (zheng > i) And ((strtofloat(LowerSL) - trunc(strtofloat(LowerSL))) <> 0) Then
ch := ch + '點(diǎn)';
If zheng > i Then
For j := j + 1 To zheng - 1 Do
If (LowerSL[j] = '0') And ((strtofloat(LowerSL) - trunc(strtofloat(LowerSL))) <> 0) Then
ch := ch + '零'
Else
ch := ch + a[StrToInt(LowerSL[j])];
End
Else
Begin
If (trunc(strtofloat(LowerSL)) = 0) And (zheng = i) Then
ch := ch + '零'
Else
For j := 1 To i - 1 Do
If (LowerSL[j] = '0') And (LowerSL[j + 1] = '0') Then
Begin
continue;
End
Else If (LowerSL[j] = '0') And (LowerSL[j + 1] <> '0') And //
(LowerSL[j + 1] <> '') And (LowerSL[j + 1] <> '.') Then
// 這三行是處理中間的零。
ch := ch + a[StrToInt(LowerSL[j])] + '零' //
Else If (i = 2) And (LowerSL[j] = '0') And (LowerSL[j + 1] = '.') Then
ch := ch + '零' //判斷是否是小數(shù)。
Else If (i - j = 6) And (LowerSL[j + 1] <> '0') Then //判斷是否是十萬(wàn)位
ch := ch + a[StrToInt(LowerSL[j])] + '拾'
Else If (i - j = 7) And (LowerSL[j + 1] <> '0') Then
ch := ch + a[StrToInt(LowerSL[j])] + '佰' //判斷是否是佰萬(wàn)位
Else If (i - j = 8) And (LowerSL[j + 1] <> '0') Then
ch := ch + a[StrToInt(LowerSL[j])] + '仟' //判斷是否是仟萬(wàn)位
Else If (i - j = 10) And (LowerSL[j + 1] <> '0') Then
ch := ch + a[StrToInt(LowerSL[j])] + '拾' //判斷是否是十億位
Else If (i - j = 11) And (LowerSL[j + 1] <> '0') Then
ch := ch + a[StrToInt(LowerSL[j])] + '佰' //判斷是否是佰億位
Else If (i - j = 12) And (LowerSL[j + 1] <> '0') Then
ch := ch + a[StrToInt(LowerSL[j])] + '仟' //判斷是否是仟億位
Else
ch := ch + A[StrToInt(LowerSL[j])] + b[I - j];
If (zheng > i) And ((strtofloat(LowerSL) - trunc(strtofloat(LowerSL))) <> 0) Then
ch := ch + '點(diǎn)';
If zheng > i Then
For j := j + 1 To zheng - 1 Do
If (LowerSL[j] = '0') And ((strtofloat(LowerSL) - trunc(strtofloat(LowerSL))) <> 0) Then
ch := ch + '零'
Else
ch := ch + a[StrToInt(LowerSL[j])];
End;
Result := '';
Result := ch;
End;
Function SmallToBig4(Const rmbSmall: Currency): String;
Var
NumStr: Array[1..10] Of String; //漢字大寫(xiě)的數(shù)字
Sign: Array[1..12] Of String; //漢字大寫(xiě)的單位
IntPart, //整數(shù)部分
RealPart, //小數(shù)部分
UpperMoney, LowerMoney: String;
i, j: Integer; //循環(huán)變量
Begin
//開(kāi)始初始化數(shù)組
LowerMoney := FloatToStr(rmbSmall);
NumStr[1] := '零';
NumStr[2] := '壹';
NumStr[3] := '貳';
NumStr[4] := '叁';
NumStr[5] := '肆';
NumStr[6] := '伍';
NumStr[7] := '陸';
NumStr[8] := '柒';
NumStr[9] := '捌';
NumStr[10] := '玖';
Sign[1] := '元';
Sign[2] := '拾';
Sign[3] := '佰';
Sign[4] := '仟';
Sign[5] := '萬(wàn)';
Sign[6] := '拾';
Sign[7] := '佰';
Sign[8] := '仟';
Sign[9] := '億';
Sign[10] := '拾';
Sign[11] := '佰';
Sign[12] := '仟';
//初始化數(shù)組結(jié)束,開(kāi)始初始化字符串
IntPart := '';
RealPart := '';
UpperMoney := '';
//初始化字符串結(jié)束,開(kāi)始給字符串賦值
IntPart := FloatToStr(Int(StrToFloat(LowerMoney)));
RealPart := FloatToStr(Frac(StrToFloat(LowerMoney)));
//字符串賦值結(jié)束,開(kāi)始數(shù)字和漢字轉(zhuǎn)換
j := 1;
For i := Length(IntPart) Downto 1 Do
Begin
UpperMoney := NumStr[StrToInt(IntPart[i]) + 1] + Sign[j] + UpperMoney;
j := j + 1;
End;
//結(jié)束數(shù)字和漢字的轉(zhuǎn)換,開(kāi)始去掉多余的 0
If Length(IntPart) >= 2 Then //當(dāng)是二位數(shù)時(shí)...
If (IntPart[Length(IntPart)] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 2] := ' ';
UpperMoney[Length(UpperMoney) - 3] := ' ';
End;
If Length(IntPart) >= 3 Then //當(dāng)是三位數(shù)時(shí)...
If (IntPart[Length(IntPart) - 1] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 4] := ' ';
UpperMoney[Length(UpperMoney) - 5] := ' ';
If (IntPart[Length(IntPart)] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 6] := ' ';
UpperMoney[Length(UpperMoney) - 7] := ' ';
End;
End;
If Length(IntPart) >= 4 Then //當(dāng)是四位數(shù)時(shí)...
If (IntPart[Length(IntPart) - 2] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 8] := ' ';
UpperMoney[Length(UpperMoney) - 9] := ' ';
If (IntPart[Length(IntPart) - 1] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 10] := ' ';
UpperMoney[Length(UpperMoney) - 11] := ' ';
End;
End;
If Length(IntPart) >= 5 Then //當(dāng)是五位數(shù)時(shí)...
If (IntPart[Length(IntPart) - 3] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 12] := ' ';
UpperMoney[Length(UpperMoney) - 13] := ' ';
If (IntPart[Length(IntPart) - 2] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 14] := ' ';
UpperMoney[Length(UpperMoney) - 15] := ' ';
End;
End;
If Length(IntPart) >= 6 Then //當(dāng)是六位數(shù)時(shí)...
If (IntPart[Length(IntPart) - 4] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 18] := ' ';
UpperMoney[Length(UpperMoney) - 19] := ' ';
If (IntPart[Length(IntPart) - 3] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 13] := ' ';
UpperMoney[Length(UpperMoney) - 14] := ' ';
End;
End;
If Length(IntPart) >= 7 Then //當(dāng)是七位數(shù)時(shí)...
If (IntPart[Length(IntPart) - 5] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 20] := ' ';
UpperMoney[Length(UpperMoney) - 21] := ' ';
If (IntPart[Length(IntPart) - 4] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 18] := ' ';
UpperMoney[Length(UpperMoney) - 19] := ' ';
UpperMoney[Length(UpperMoney) - 22] := ' ';
UpperMoney[Length(UpperMoney) - 23] := ' ';
End;
End;
If Length(IntPart) >= 8 Then //當(dāng)是八位數(shù)時(shí)...
If (IntPart[Length(IntPart) - 6] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 24] := ' ';
UpperMoney[Length(UpperMoney) - 25] := ' ';
If (IntPart[Length(IntPart) - 5] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 20] := ' ';
UpperMoney[Length(UpperMoney) - 21] := ' ';
UpperMoney[Length(UpperMoney) - 22] := ' ';
UpperMoney[Length(UpperMoney) - 23] := ' ';
If (IntPart[Length(IntPart) - 4] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 18] := ' ';
UpperMoney[Length(UpperMoney) - 19] := ' ';
UpperMoney[Length(UpperMoney) - 26] := ' ';
UpperMoney[Length(UpperMoney) - 27] := ' ';
End;
End;
End;
If Length(IntPart) >= 9 Then //當(dāng)是九位數(shù)時(shí)...
If (IntPart[Length(IntPart) - 7] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 28] := ' ';
UpperMoney[Length(UpperMoney) - 29] := ' ';
If (IntPart[Length(IntPart) - 6] = '0') Then
Begin
UpperMoney[Length(UpperMoney) - 24] := ' ';
UpperMoney[Length(UpperMoney) - 25] := ' ';
UpperMoney[Length(UpperMoney) - 26] := ' ';
UpperMoney[Length(UpperMoney) - 27] := ' ';
UpperMoney[Length(UpperMoney) - 28] := ' ';
UpperMoney[Length(UpperMoney) - 29] := ' ';
UpperMoney[Length(UpperMoney) - 30] := ' ';
UpperMoney[Length(UpperMoney) - 31] := ' ';
End;
End;
//結(jié)束去掉多余的 0 ,開(kāi)始轉(zhuǎn)換小數(shù)部分
If Length(RealPart) = 1 Then
UpperMoney := UpperMoney + '整';
If Length(RealPart) = 3 Then
Begin
If IntPart[Length(IntPart)] = '0' Then
UpperMoney := UpperMoney + '零';
UpperMoney := UpperMoney + NumStr[StrToInt(RealPart[3]) + 1] + '角整';
End;
If Length(RealPart) >= 4 Then
Begin
If RealPart[3] = '0' Then
Begin
UpperMoney := UpperMoney + '零';
If RealPart[4] = '0' Then
Begin
UpperMoney[Length(UpperMoney)] := ' ';
UpperMoney[Length(UpperMoney) - 1] := ' ';
End
Else
UpperMoney := UpperMoney + NumStr[StrToInt(RealPart[4]) + 1] + '分';
End;
If RealPart[3] <> '0' Then
Begin
If IntPart[Length(IntPart)] = '0' Then
UpperMoney := UpperMoney + '零';
UpperMoney := UpperMoney + NumStr[StrToInt(RealPart[3]) + 1] + '角';
If RealPart[4] <> '0' Then
UpperMoney := UpperMoney + NumStr[StrToInt(RealPart[4]) + 1] + '分'
Else
UpperMoney := UpperMoney + '整';
End;
End;
Result := '';
For i := 1 To Length(UpperMoney) Do
If UpperMoney[i] <> ' ' Then
Result := Result + UpperMoney[i];
End;
Function SmallToBig3(Const rmbSmall: Currency): String;
Var
i, j: Integer;
zheng: Integer;
ch, Money: String;
A: Array[1..10] Of String;
B: Array[1..12] Of String;
C: Array[1..2] Of String;
Begin
A[1] := '壹';
A[2] := '貳';
A[3] := '叁';
A[4] := '肆';
A[5] := '伍';
A[6] := '陸';
A[7] := '柒';
A[8] := '捌';
A[9] := '玖';
A[10] := '拾';
B[1] := '';
B[2] := '拾';
B[3] := '佰';
B[4] := '仟';
B[5] := '萬(wàn)';
B[6] := '拾萬(wàn)';
B[7] := '佰萬(wàn)';
B[8] := '仟萬(wàn)';
B[9] := '億';
B[10] := '拾億';
B[11] := '佰億';
B[12] := '仟億';
B[12] := '';
C[1] := '分';
C[2] := '角';
//l:=trunc(strtofloat(money));
Try
money := floattostr(rmbSmall);
Except
ShowError('你轉(zhuǎn)換的數(shù)值是一個(gè)無(wú)效的類型');
exit;
End;
money := formatfloat('0.00', strtofloat(money));
zheng := length(money) + 1;
i := length(IntToStr(trunc(strtofloat(money)))) + 1;
For j := 1 To i - 1 Do
If (money[j] = '0') And (money[j + 1] = '0') Then
continue //判斷中間的零
Else If (money[j] = '0') And ((money[j + 1] <> '0') And (money[j + 1] <> '') And
(money[j + 1] <> '.')) Then
ch := ch + A[StrToInt(money[j])] + '零' //得到中間的零
Else If (i - j = 6) And (money[j + 1] <> '0') Then
ch := ch + A[StrToInt(money[j])] + '拾' //拾萬(wàn)數(shù)
Else If (i - j = 7) And (money[j + 1] <> '0') Then
ch := ch + A[StrToInt(money[j])] + '佰' //佰萬(wàn)數(shù)
Else If (i - j = 8) And (money[j + 1] <> '0') Then
ch := ch + a[StrToInt(money[j])] + '仟' //仟萬(wàn)數(shù)
Else If (i - j = 10) And (money[j + 1] <> '0') Then
ch := ch + A[StrToInt(money[j])] + '拾' //拾億數(shù)
Else If (i - j = 11) And (money[j + 1] <> '0') Then
ch := ch + A[StrToInt(money[j])] + '佰' //佰億數(shù)
Else If (i - j = 12) And (money[j + 1] <> '0') Then
ch := ch + A[StrToInt(money[j])] + '仟' //仟億數(shù)
Else
Begin
ch := ch + A[StrToInt(money[j])] + b[i - j];
End;
ch := ch + '元';
//if (i>2) and (money[i-1]='0') and (money[i+1]<>'0')then
// ch:=ch+'零';
j := i;
If zheng > i Then
For j := j + 1 To zheng - 1 Do
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -