转贴一个,忘了作者,希望不会被骂。。。
function TForm1.NumToChnStr(Value: Real; ClearZero: Boolean): String;
const
ChnUnit: array[0..13] of string = ('分', '角', '元', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿', '拾', '佰', '仟');
ChnNum : array[0..9] of string = ('零', '壹','贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖');
var
I: Integer;
StrValue, StrNum: String;
ValueLen: Integer;
begin
if Value <= 0 then
begin
Result := '输入参数应大于零。';
Exit;
end;
StrValue := IntToStr(Round(Value * 100));
ValueLen := Length(StrValue);
Result := '';
for I := 1 to ValueLen do
begin
StrNum := StrValue;
Result := Result + ChnNum[StrToInt(StrNum)] + ChnUnit[ValueLen - I];
end;
if ClearZero then
begin
Result := StringReplace(Result, '零分', '', [rfReplaceAll]);
Result := StringReplace(Result, '零角', '', [rfReplaceAll]);
Result := StringReplace(Result, '零元', '元', [rfReplaceAll]);
Result := StringReplace(Result, '零拾', '', [rfReplaceAll]);
Result := StringReplace(Result, '零佰', '', [rfReplaceAll]);
Result := StringReplace(Result, '零仟', '', [rfReplaceAll]);
Result := StringReplace(Result, '零万', '万', [rfReplaceAll]);
end;
end;