Pascal Code
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
unit
Functioncal; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TForm5 = class (TForm) lbl1: TLabel; edt1: TEdit; lbl2: TLabel; edt2: TEdit; btn1: TButton; lbl3: TLabel; edt3: TEdit; procedure btn1Click(Sender: TObject); function ADD( const A: Integer ; const B: Integer ): Integer ; //常量参数,不能修改参数 private { Private declarations } public { Public declarations } end ; var Form5: TForm5; implementation {$R *.dfm} function TForm5.ADD( const A: Integer ; const B: Integer ): Integer ; //常量参数函数实现 begin result := A+ B; end ; procedure TForm5.btn1Click(Sender: TObject); var x : Integer ; y : Integer ; begin x := StrToInt(edt1. Text ); y := StrToInt(edt2. Text ); edt3. Text := IntToStr(ADD(x,y)); //调用常量参数函数 end ; end . |