Iseng-iseng ngulik sedikit syntax program, alhamdulillah berhasil, semoga bermanfaat untuk anda :-)
Buat sebuah VCL Form Application baru (cukup 1 form saja), letakan satu buah label ke dalam form. Disini saya menggunakan sebuah procedure yang saya buat sendiri (namanya: Salam), lalu procedure itu saya panggil saat event OnCreate.
Syntax nya seperti ini:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure Salam;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Salam;
end;
procedure TForm1.Salam;
begin
if time()>strtotime('18:00:00') then
label1.Caption:='Selamat malam...'
else
if time()>strtotime('15:00:00') then
label1.Caption:='Selamat sore...'
else
if time()>strtotime('10:00:00') then
label1.Caption:='Selamat siang...'
else
if time()>strtotime('00:00:00') then
label1.Caption:='Selamat pagi...'
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure Salam;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Salam;
end;
procedure TForm1.Salam;
begin
if time()>strtotime('18:00:00') then
label1.Caption:='Selamat malam...'
else
if time()>strtotime('15:00:00') then
label1.Caption:='Selamat sore...'
else
if time()>strtotime('10:00:00') then
label1.Caption:='Selamat siang...'
else
if time()>strtotime('00:00:00') then
label1.Caption:='Selamat pagi...'
end;
end.
Post a Comment