- 好友
- 0
- 帖子
- 124731
- 積分
- 124889
- 最後登錄
- 2019-2-28
- 在線時間
- 0 小時
- 好友
- 0
- 帖子
- 124731
- 積分
- 124889
- 最後登錄
- 2019-2-28
- 在線時間
- 0 小時
|
<div class="blockcode"><span class="headactions" onclick="copycode($('code0'));">複製內容到剪貼板</span><h5>代碼:</h5><code id="code0">unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure SayHello(const sWhat:String);
begin
ShowMessage('Hello ' + sWhat);
end;
function YearsOld(const BirthYear:Integer) : Integer;
var
Year, Month, Day : word;
begin
DecodeDate(Date, Year, Month, Day);
Result := Year - BirthYear;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SayHello('Delphi User');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
SayHello('Zarko Gajic');
ShowMessage('You are ' + IntToStr(YearsOld(1973)) + 'years old!');
end;
end.</code> |
|