unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var min,Max,value:Extended;
procedure TForm1.Button1Click(Sender: TObject);
begin
min:=StrToInt(Edit1.text);
max:=strtoint(Edit2.text);//被除数不能为0
if Max=0 then Exit;
value:= (min / max)*100;
Edit3.text:=Format('%f',[value])+'%';
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.text:='0';
Edit2.text:='1';
Edit3.text:='0%';
Edit3.Enabled:=false;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var min,Max,value:Extended;
procedure TForm1.Button1Click(Sender: TObject);
begin
min:=StrToInt(Edit1.text);
max:=strtoint(Edit2.text);//被除数不能为0
if Max=0 then Exit;
value:= (min / max)*100;
Edit3.text:=Format('%f',[value])+'%';
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.text:='0';
Edit2.text:='1';
Edit3.text:='0%';
Edit3.Enabled:=false;
end;
end.