- function MoneyToUpper(const NumBer: Double): string;
- var StrNumber, AUpperNum, AMoneyUnit: string;
- UpperNum: array[0..9] of string;
- MoneyUnit: array[1..16] of string;
- I: Integer;
- AZero: Boolean;
- N: Double;
- begin
- UpperNum[1] := '壹';
- UpperNum[2] := '贰';
- UpperNum[3] := '叁';
- UpperNum[4] := '肆';
- UpperNum[5] := '伍';
- UpperNum[6] := '陆';
- UpperNum[7] := '柒';
- UpperNum[8] := '捌';
- UpperNum[9] := '玖';
- MoneyUnit[1] := '万';
- MoneyUnit[2] := '仟';
- MoneyUnit[3] := '佰';
- MoneyUnit[4] := '拾';
- MoneyUnit[5] := '亿';
- MoneyUnit[6] := '仟';
- MoneyUnit[7] := '佰';
- MoneyUnit[8] := '拾';
- MoneyUnit[9] := '万';
- MoneyUnit[10] := '仟';
- MoneyUnit[11] := '佰';
- MoneyUnit[12] := '拾';
- MoneyUnit[13] := '元';
- MoneyUnit[14] := '.';
- MoneyUnit[15] := '角';
- MoneyUnit[16] := '分';
- AZero := False;
- AUpperNum := '';
- AMoneyUnit := '';
- result := '';
- if NumBer < 0 then
- begin
- result := '负';
- N := -NumBer;
- end
- else
- N := NumBer;
- Str(N: 16: 2, StrNumber);
- for I := 1 to 16 do
- begin
- if StrNumber[I] <> ' ' then
- begin
- AMoneyUnit := MoneyUnit[I];
- if StrNumber[I] = '0' then
- begin
- if AZero and (copy(result, Length(result) - 1, 2) = '零') then
- result := copy(result, 1, Length(result) - 2);
- case I of
- 1..4, 6..8, 10..12: begin // 万,仟,佰,拾
- AUpperNum := '零';
- AMoneyUnit := '';
- end;
- 5, 9, 13: begin // 亿,万,元
- if StrToFloat(StrNumber) < 1 then AMoneyUnit := '';
- AUpperNum := '';
- end;
- 15: begin // 角
- if StrToFloat(StrNumber) < 1 then AUpperNum := ''
- else AUpperNum := '零';
- AMoneyUnit := '';
- end;
- 16: begin // 分
- AUpperNum := '';
- AMoneyUnit := '';
- end;
- end;
- AZero := True;
- end
- else
- begin
- if StrNumber[I] = '.' then
- begin
- AUpperNum := '';
- AMoneyUnit := '';
- end
- else
- begin
- AZero := False;
- AUpperNum := UpperNum[StrToInt(StrNumber[I])];
- end
- end;
- result := result + (AUpperNum + AMoneyUnit)
- end;
- end;
- result := result + '整';
- end;