⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gasitemform.pas

📁 delphi com深入编程,非常有收藏价值
💻 PAS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -