//将人民币小写转换成大写
unit RMBTRANS;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TResolution=(yuan,jiao,fen,li);
TRMBTRANS = class(TComponent)
private
FBigString:String;
FSmall: Double;
Fmoneyunit:TResolution;
function GetBigString :String;
{ Private declarations }
protected
{ Protected declarations }
public
function GetBigIndex(small: Double):String;
constructor Create(Aowner:Tcomponent);override;
{ Public declarations }
published
property Small :double read FSmall write FSmall ;
property BigString :String read GetBigString write FBigString;
property MoneyUnit:TResolution read Fmoneyunit write Fmoneyunit;// default yuan;//aeMousedown;
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('ZQVCL', [TRMBTRANS]);
end;
{ TRMBTRANS }
//人民币的小写转大写
function TRMBTRANS.GetBigString : string;
var
one : string;
small_str ,geshi: string;
smallmonth, bigmonth: string;
weil, qianweil: string[2];
qianwei, dianweizhi, qian: integer;
begin
small_str := floattostr(Small);
one := copy(small_str,1,1);
if one = '-' then
begin
delete(small_str,1,1);
Small := strtofloat(small_str);
end;
case Fmoneyunit of
li: begin
geshi:='0.000';
qianwei:=-3;
end;
fen: begin
geshi:='0.00';
qianwei:=-2;
end;
jiao: begin
geshi:='0.0';
qianwei:=-1;
end;
yuan: begin
geshi:='0';
qianwei:=0;
end;
end;
smallmonth:=formatfloat(geshi,Small);
dianweizhi:=pos('.',smallmonth);
for qian:=length(smallmonth) downto 1 do
begin
if qian<>dianweizhi then
begin
case strtoint(copy(smallmonth,qian,1)) of
1:weil:='壹'; 2:weil:='贰';
3:weil:='叁'; 4:weil:='肆';
5:weil:='伍'; 6:weil:='陆';
7:weil:='柒'; 8:weil:='捌';
9:weil:='玖'; 0:weil:='零';
end;
case qianwei of
-3:qianweil:='厘';
-2:qianweil:='分';
-1:qianweil:='角';
0:qianweil:='元';
1:qianweil:='拾';
2:qianweil:='佰';
3:qianweil:='千';
4:qianweil:='万';
5:qianweil:='拾';
6:qianweil:='佰';
7:qianweil:='千';
8:qianweil:='亿';
9:qianweil:='十';
10:qianweil:='佰';
11:qianweil:='千';
end;
inc(qianwei);
bigmonth:=weil+qianweil+bigmonth;
end;
end;
if one = '-' then result := '负'+bigmonth
else result := bigmonth;
end;
function TRMBTRANS.GetBigIndex(small: Double): String;
begin
FSmall := small;
result := GetBigString;
end;
constructor TRMBTRANS.Create(Aowner:Tcomponent);
begin
inherited Create(Aowner);
Fmoneyunit:=yuan;
end;
end.