答案:unit Unit1;
inte易做图ce
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, WinSkinData;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
Button2: TButton;
Edit2: TEdit;
SkinData1: TSkinData;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
function Small2Big(SourceMoney:Currency):string;
var
//strSourceMoney 未转换小写字符
// strObjectMoney 以转换大写字符
strSourceMoney,strObjectMoney:string;
//thiswei当前位大写
//thispos当前位人民币单位
thiswei,thispos:string[2];
//iwei 当前位置
//pospoint当前小数点位置
iwei,pospoint:integer;
begin
strSourceMoney:=formatfloat('0.00',SourceMoney);
//搜索小数点位置
pospoint:=pos('.',strSourceMoney);
for iwei:=length(strSourceMoney) downto 1 do
begin
case strSourceMoney[iwei] of
'.':Continue; //如果是小数点,不进行转换
'1':thiswei:='壹';
'2':thiswei:='贰';
'3':thiswei:='叁';
'4':thiswei:='肆';
'5':thiswei:='伍';
'6':thiswei:='陆';
'7':thiswei:='柒';
'8':thiswei:='捌';
'9':thiswei:='玖';
'0':thiswei:='零';
end;
case pospoint-iwei of
-3:thispos:='厘';
-2:thispos:='分';
-1:thispos:='角';
1:thispos:='元';
2:thispos:='拾';
3:thispos:='佰';
4:thispos:='仟';
5:thispos:='万';
6:thispos:='拾';
7:thispos:='佰';
8:thispos:='仟';
9:thispos:='亿';
10:thispos:='拾';
11:thispos:='佰';
12:thispos:='仟';
end;
strObjectMoney:=thiswei+thispos+strObjectMoney;//组合成大写金额
end;
Small2Big:=strObjectMoney
end;
procedure TForm1.Button1Click(Sender: TObject);
var
thismoney:currency;
begin
try
ThisMoney:=StrToFloat(edit1.text);
except
showmessage('please input correct number');
exit;
end;
label1.Caption := Small2Big(ThisMoney);
edit2.Text:=label1.Caption;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:=''; edit1.SetFocus ;
label1.Caption:='';
edit2.Text:='';
end;
end.
其他:问题补充:我要的是数字大小写转换不要人民币金额转换的.如text控件中有一strSourceMoney,strObjectMoney:string; //thiswei当前位大写 //thispos当前位 建立一个数组,为array[0]= '零 ',array[1]= '壹 '依此类推
当edit的press事件产生时,
用strtoint将key参数转换为integer类型i(假设i已经声明为integer类的)
然后
将edit1.text:=edit1.text+array[i]; BigMoney: array[0..9] of string=('零','壹','贰','叁','肆','伍','陆','柒','捌','玖');
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
money,tmpM,b:string;
i:integer;
begin
tmpM:='';
money:=adoquery1.fieldbyname('金额').asstring;
for i:=1 to Length(money) do
begin
tmpM:=tmpM + b[strtoint(money[i])];
Edit1.Text:=tmpM;
end;
end;
上一个:delphi 求窗体的最大边框属性的那个函数。
下一个:Delphi 7 出错