gasitemform.pas
来自「《Delphi COM深入编程》原书光盘」· PAS 代码 · 共 63 行
PAS
63 行
unit GasItemForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, ExtCtrls;
type
TfrmGasItem = class(TForm)
pnlBottom: TPanel;
pnlClient: TPanel;
btnOK: TButton;
btnCancel: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
dtDate: TDateTimePicker;
ecGallons: TEdit;
ecMileage: TEdit;
procedure btnOKClick(Sender: TObject);
private
FDate: TDateTime;
FGallons: Double;
FMileage: Double;
{ Private declarations }
public
{ Public declarations }
property Date: TDateTime read FDate;
property Gallons: Double read FGallons;
property Mileage: Double read FMileage;
end;
implementation
{$R *.DFM}
procedure TfrmGasItem.btnOKClick(Sender: TObject);
begin
FDate := dtDate.Date;
try
FGallons := StrToFloat(ecGallons.Text);
except
ModalResult := mrNone;
ActiveControl := ecGallons;
ShowMessage('Gallons is not a valid number.');
exit;
end;
try
FMileage := StrToFloat(ecMileage.Text);
except
ModalResult := mrNone;
ActiveControl := ecMileage;
ShowMessage('Mileage is not a valid number.');
exit;
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?