Delphi 实现简单计算器
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
unit Cals;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls;
type
TForm1 = class(TForm)
mm1: TMainMenu;
N1: TMenuItem;
S1: TMenuItem;
S2: TMenuItem;
edt1: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
Button11: TButton;
Button12: TButton;
Button13: TButton;
Button14: TButton;
Button15: TButton;
Button16: TButton;
Button18: TButton;
Button19: TButton;
Button20: TButton;
Button21: TButton;
Button22: TButton;
Button23: TButton;
Button25: TButton;
Button26: TButton;
Button27: TButton;
Button28: TButton;
Button29: TButton;
Button30: TButton;
edt2: TEdit;
procedure Button19Click(Sender: TObject);
procedure Button26Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button20Click(Sender: TObject);
procedure Button21Click(Sender: TObject);
procedure Button12Click(Sender: TObject);
procedure Button13Click(Sender: TObject);
procedure Button14Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button29Click(Sender: TObject);
procedure Button30Click(Sender: TObject);
procedure Button22Click(Sender: TObject);
procedure Button15Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button27Click(Sender: TObject);
procedure Button28Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure Button23Click(Sender: TObject);
procedure UpdateDisplay();
procedure Calculate();
procedure OnOperandInput(a: Integer);
procedure edt1KeyPress(Sender: TObject; var Key: Char);
procedure FormCreate(Sender: TObject);
procedure Button16Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button18Click(Sender: TObject);
procedure Button25Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
Operator = (OpNone,OpAdd,OpSubtract,OpMultiply,OpDivide);//定义枚举用以标识运算符
CalcError = (ErrNone,ErrDivideByZero); //定义枚举用以标识当前运算状态
var