Latihan 1 Objek Properti Nilai Properti
Latihan 1 Objek Properti Nilai Properti
Objek
Form1
Label1
Label2
Label3
Edit1
Edit2
Button1
Button2
Button3
Properti
Nilai Properti
Caption
Latihan 1
Caption
DATA MAHASISWA
Font
Name: Tahoma, Size: 15,
Style: fsBold (True)
Caption
NAMA
Font
Name: Tahoma, Size: 12
Caption
ALAMAT
Font
Name: Tahoma, Size: 12
Text
(kosong)
Text
(kosong)
Caption
Proses
Caption
Hapus
Caption
Keluar
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
1
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label4: TLabel;
Label5: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
label4.Caption:=edit1.Text;
label5.Caption:=edit2.Text;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
label4.Caption:='';
edit1.Text:='';
label5.Caption:='';
edit2.Text:='';
edit1.setfocus;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
application.Terminate;
end;
end.
LATIHAN 2
Objek
Form1
Label1
Label2
Label3
Label4
Label5
Edit1
Edit2
Button1
Button2
Button3
Button4
Button5
Button6
Button7
Button8
Properti
Nilai Properti
Caption
Latihan 2
Caption
DATA MAHASISWA
Font
Name: Tahoma, Size: 15,
Style: fsBold (True)
Caption
NAMA
Font
Name: Tahoma, Size: 12
Caption
ALAMAT
Font
Name: Tahoma, Size: 12
Caption
(kosong)
Caption
(kosong)
Text
(kosong)
Text
(kosong)
Caption
Proses
Caption
Verdana
Caption
Lucida
Caption
Ukuran 20
Caption
Merah
Caption
Biru
Caption
Normal
Caption
Keluar
unit Unit1;
interface
uses
3
Label5.Caption:=edit2.Text;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
label4.Font.Name:='verdana';
label5.Font.Name:='verdana';
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
label4.Font.size:=20;
label5.Font.Size:=20;
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
label4.Font.Name:='Ms sans serif';
label5.Font.Name:='Ms Sans Serif';
label4.Font.size:=8;
label5.Font.Size:=8;
label4.Font.Color:=cldefault;
label5.Font.color:=cldefault;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
label4.Font.Color:=clblue;
label5.Font.color:=clblue;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
label4.Font.Color:=clred;
label5.Font.color:=clred;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
label4.Font.Name:='Lucida handwriting';
label5.Font.Name:='Lucida handwriting';
5
end;
end.
LATIHAN 3
Objek
Form1
Label1
Button1
Button2
Button3
Properti
Nilai Properti
Caption
Latihan 3
Caption
Tombol Belum Ditekan
Font
Name: Tahoma, Size: 14,
Style: fsBold (True)
Caption
Belum ditekan
Caption
Belum direset
Enabled
False
Caption
Keluar
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
7
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
label1.Caption:='Tombol Sudah Ditekan';
button2.Caption:='Belum Direset';
button1.Caption:='Sudah Ditekan';
button1.Enabled:=false;
button2.enabled:=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
button1.enabled:=true;
button2.enabled:=false;
button1.Caption:='Belum Ditekan';
button2.Caption:='Sudah Direset';
Label1.Caption:='Tombol Sudah Direset';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Application.Terminate;
end;
end.
LATIHAN 4
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
ComboBox1: TComboBox;
ListBox1: TListBox;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Button1: TButton;
Button2: TButton;
procedure Edit1Change(Sender: TObject);
procedure Edit2Change(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
9
Label7.caption:='';
Label8.caption:='';
Label9.caption:='';
Edit1.setfocus;
end;
end.
11
LATIHAN 5
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
ck1: TCheckBox;
ck2: TCheckBox;
ck3: TCheckBox;
ck4: TCheckBox;
ck5: TCheckBox;
ck6: TCheckBox;
ck7: TCheckBox;
ck8: TCheckBox;
ck9: TCheckBox;
ck10: TCheckBox;
ck11: TCheckBox;
ck12: TCheckBox;
memo1: TMemo;
Button3: TButton;
12
if
ck7.Checked
then
memo1.Lines.add(ck7.Caption);
if
ck8.Checked
then
memo1.Lines.add(ck8.Caption);
if
ck9.Checked
then
memo1.Lines.add(ck9.Caption);
if
ck10.Checked
then
memo1.Lines.add(ck10.Caption);
if
ck11.Checked
then
memo1.Lines.add(ck11.Caption);
if
ck12.Checked
then
memo1.Lines.add(ck12.Caption);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ck1.Checked:=false;
ck2.Checked:=false;
ck3.Checked:=false;
ck4.Checked:=false;
ck5.Checked:=false;
ck6.Checked:=false;
ck7.Checked:=false;
ck8.Checked:=false;
ck9.Checked:=false;
ck10.Checked:=false;
ck11.Checked:=false;
ck12.Checked:=false;
memo1.lines.Clear;
end;
end.
14
LATIHAN 6
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls, jpeg,
ExtCtrls;
type
TForm1 = class(TForm)
Button2: TButton;
Image1: TImage;
Label1: TLabel;
Button4: TButton;
Label2: TLabel;
Button1: TButton;
Button3: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
15
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
begin
image1.picture.LoadFromFile('b.jpg');
button1.Enabled:=true;
button2.Enabled:=false;
button3.Enabled:=true;
Label2.Caption:='Gambar 2';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
image1.picture.LoadFromFile('a.jpg');
button1.Enabled:=false;
button2.Enabled:=true;
button3.Enabled:=true;
Label2.Caption:='Gambar 1';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
image1.picture.LoadFromFile('c.jpg');
button1.Enabled:=true;
button2.Enabled:=true;
button3.Enabled:=false;
Label2.Caption:='Gambar 3';
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
Application.Terminate;
end;
end.
16
LATIHAN 7
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
rg1: TRadioGroup;
Edit1: TEdit;
Label1: TLabel;
Edit2: TEdit;
Button1: TButton;
Edit3: TEdit;
Button3: TButton;
Button2: TButton;
procedure rg1Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
a,b,c:real;
implementation
17
{$R *.dfm}
procedure TForm1.rg1Click(Sender: TObject);
begin
if rg1.ItemIndex=0 then
begin
Label1.Caption:='X';
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
end else if rg1.ItemIndex=1 then
begin
Label1.Caption:='+';
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
end else if rg1.ItemIndex=2 then
begin
Label1.Caption:='-';
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
end else if rg1.ItemIndex=3 then
begin
Label1.Caption:='/';
Edit1.Text:='';
Edit2.Text:='';
Edit3.Text:='';
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if rg1.ItemIndex=0 then
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
c:=b*a;
edit3.Text:=floattostr(c);
end else if rg1.ItemIndex=1 then
18
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
c:=b+a;
edit3.Text:=floattostr(c);
end else if rg1.ItemIndex=2 then
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
c:=a-b;
edit3.Text:=floattostr(c);
end else if rg1.ItemIndex=3 then
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
if b=0 then
begin messagedlg ('Goblok!!? 0 Tidak Bisa
Untuk Membagi',mtwarning,[mbOk],0);
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
end else
c:=a/b;
edit3.Text:=floattostr(c);
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
end;
end.
19
20
LATIHAN 8
unit Unit12;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, ExtCtrls,jpeg,
StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Panel1: TPanel;
RichEdit1: TRichEdit;
Image1: TImage;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
21
interface
uses
Windows, SysUtils, Classes, Graphics,
Controls, StdCtrls, Buttons, ExtCtrls;
type
TAboutBox = class(TForm)
Panel1: TPanel;
ProgramIcon: TImage;
ProductName: TLabel;
Version: TLabel;
Copyright: TLabel;
Comments: TLabel;
OKButton: TButton;
Label1: TLabel;
private
{ Private declarations }
public
{ Public declarations }
end;
var
AboutBox: TAboutBox;
implementation
{$R *.dfm}
end.
Forms,
23
LATIHAN 9
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
label5: TLabel;
edit1: TEdit;
edit2: TEdit;
edit3: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label6: TLabel;
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
24
{ Public declarations }
end;
var
Form1: TForm1;
n,p,t,v: real;
const
R=0.081;
implementation
{$R *.dfm}
procedure TForm1.Button3Click(Sender: TObject);
begin
application.terminate;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
v:=strtofloat(edit1.text);
t:=strtofloat(edit2.text);
n:=strtofloat(edit3.text);
p:=(n*R*T)/v;
label6.Caption:=floattostr(p);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.text:='';
edit2.text:='';
edit3.text:='';
label6.Caption:='';
end;
end.
25
LATIHAN 10
unit Ulat11;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x,y:real;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
26
begin
application.Terminate;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
y:=strtofloat(edit1.Text);
x:=sqrt(y);
label2.Caption:='Akar dari ' + edit1.Text + '
adalah ' + floattostr(x);
edit1.SetFocus;
end;
end.
27
LATIHAN 11
unit Ulat12;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
28
end;
var
Form1: TForm1;
a,b,c:real;
implementation
{$R *.dfm}
procedure TForm1.Button3Click(Sender: TObject);
begin
application.Terminate;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
b:=strtofloat(edit1.Text);
c:=strtofloat(edit2.Text);
a:=exp(c*ln(b));
label3.Caption:=edit1.Text;
label4.Caption:=edit2.Text;
label5.Caption:=' = '+floattostr(a);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
label3.Caption:='';
label4.Caption:='';
label5.Caption:='';
edit1.SetFocus;
end;
end.
29
LATIHAN 12
unit Ulat13;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
30
public
{ Public declarations }
end;
var
Form1: TForm1;
n,i:byte;
m,a:real;
e:double;
const
h=6.62e-34;
ev=1.6e+19;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
n:=strtoint(edit1.Text);
m:=strtofloat(edit2.Text);
a:=strtofloat(edit3.Text);
for i:=1 to n do
begin
e:=(sqr(h)*sqr(i))/(8*m*sqr(a));
e:=e*ev;
memo1.Lines.Add('Lintasan = ' +
inttostr(i) + ' maka E = '+floattostr(e)+ '
eV');
memo1.Lines.Add('');
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
memo1.Lines.Clear;
edit1.setfocus;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
31
application.Terminate;
end;
end.
32
LATIHAN 13
unit Ulat14;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
33
Label18: TLabel;
Label19: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Var
Form1: TForm1;
a,b,c,d,e,f,g,h:real;
Const
ksp=1.8e-10;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
c:=strtofloat(edit3.Text);
d:=strtofloat(edit4.Text);
e:=a+c;
f:=b/e;
g:=d/e;
h:=f*g;
label13.Caption:=floattostr(a) + ' liter larutan
mengandung ' + floattostr(b) + ' mol Cl-';
label14.Caption:=floattostr(c) + ' liter larutan
mengandung ' + floattostr(d) + ' mol Ag+';
34
35
LATIHAN 14
unit Ugab3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, ExtCtrls, shellapi,
StdCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
RadioGroup1: TRadioGroup;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
36
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, shellapi, StdCtrls,
ComCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label1: TLabel;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
RichEdit1: TRichEdit;
Button8: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Var
Form2: TForm2;
implementation
uses Ugab1, Ugab3;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
38
application.Terminate;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
form2.Visible:=false;
form1.Visible:=true;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
form2.Visible:=false;
form3.Visible:=true;
end;
procedure TForm2.Button4Click(Sender: TObject);
begin
shellexecute(handle,'open','latihan1.exe',nil,nil,sw
_show);
end;
procedure TForm2.Button5Click(Sender: TObject);
begin
shellexecute(handle,'open','latihan2.exe',nil,nil,sw
_show);
end;
procedure TForm2.Button6Click(Sender: TObject);
begin
shellexecute(handle,'open','latihan3.exe',nil,nil,sw
_show);
end;
procedure TForm2.Button7Click(Sender: TObject);
begin
shellexecute(handle,'open','latihan4.exe',nil,nil,sw
_show);
end;
procedure TForm2.Button8Click(Sender: TObject);
begin
richedit1.Visible:=true;
richedit1.Lines.LoadFromFile('tulisan.rtf');
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
39
richedit1.Visible:=false;
end;
end.
40
LATIHAN 15
unit Ulatfilm;
interface
uses
Windows, jpeg, shellapi, mplayer,Messages, SysUtils,
Variants, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
RichEdit1: TRichEdit;
Label1: TLabel;
StatusBar1: TStatusBar;
Image1: TImage;
Panel1: TPanel;
MediaPlayer1: TMediaPlayer;
Button4: TButton;
Button5: TButton;
Image2: TImage;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
41
mediaplayer1.FileName:='data/film.mpg';
mediaplayer1.open;
panel1.show;
mediaplayer1.display:=panel1;
mediaplayer1.displayrect:=rect(2,2,width,height);
mediaplayer1.play;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
image2.Visible:=true;
image1.Visible:=false;
richedit1.Visible:=false;
panel1.Visible:=false;
button4.Visible:=false;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
mediaplayer1.Stop;
button1.Enabled:=true;
button2.Enabled:=true;
button3.Enabled:=true;
button4.Visible:=false;
panel1.Visible:=false;
image2.Visible:=true;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if messagedlg ('Anda yakin akan keluar ?',
mtconfirmation, mbokcancel,0) = mrok then
application.Terminate;
end;
end.
43
LATIHAN 16
unit ulatsoal;
interface
uses
Windows, shellapi, Messages, SysUtils, Variants,
Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls,
StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
re1: TRichEdit;
Kalkulator: TButton;
SPU: TButton;
Label1: TLabel;
Waktu: TLabel;
Label3: TLabel;
A: TButton;
B: TButton;
C: TButton;
D: TButton;
Edit1: TEdit;
Ket1: TLabel;
Ket2: TLabel;
Mulai: TButton;
44
next: TButton;
keluar: TButton;
Timer: TTimer;
StatusBar1: TStatusBar;
procedure KalkulatorClick(Sender: TObject);
procedure SPUClick(Sender: TObject);
procedure keluarClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure MulaiClick(Sender: TObject);
procedure nextClick(Sender: TObject);
procedure AClick(Sender: TObject);
procedure BClick(Sender: TObject);
procedure CClick(Sender: TObject);
procedure TimerTimer(Sender: TObject);
procedure DClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Var
Form1: TForm1;
xb,fni,js,jb,x:integer;
xs,fns,jss,jbs,filename:string;
implementation
{$R *.dfm}
procedure TForm1.KalkulatorClick(Sender: TObject);
begin
shellexecute(handle,'open','soal/calc.exe',nil,nil,sw_
show);
end;
procedure TForm1.SPUClick(Sender: TObject);
begin
shellexecute(handle,'open','soal/spu.exe',nil,nil,sw_
show);
end;
procedure TForm1.keluarClick(Sender: TObject);
begin
IF messagedlg ('Anda yakin Akan Keluar ?',
45
mtConfirmation,mbOkCancel,0)
=mrOk then
Application.Terminate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
label1.Visible:=false;
label3.Visible:=false;
waktu.Visible:=false;
a.Visible:=false;
b.Visible:=false;
c.Visible:=false;
d.Visible:=false;
edit1.Visible:=false;
ket1.Visible:=false;
ket2.Visible:=false;
next.Visible:=false;
re1.Visible:=false;
end;
procedure TForm1.MulaiClick(Sender: TObject);
begin
label1.Visible:=true;
label3.Visible:=true;
waktu.Visible:=true;
a.Visible:=true;
b.Visible:=true;
c.Visible:=true;
d.Visible:=true;
edit1.Visible:=true;
ket1.Visible:=true;
ket2.Visible:=true;
next.Visible:=true;
re1.Visible:=true;
mulai.Visible:=false;
filename:='11';
re1.Lines.LoadFromFile('soal/'+filename+'.rtf');
js:=1;
jss:=inttostr(js);
ket1.Caption:='Jumlah Soal : '+jss;
46
jb:=0;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar : '+jbs;
timer.Enabled:=true;
x:=0;
end;
procedure TForm1.nextClick(Sender: TObject);
begin
edit1.text:='';
a.Enabled:=true;
b.Enabled:=true;
c.Enabled:=true;
d.Enabled:=true;
re1.visible:=true;
js:=js+1;
fni:=strtoint(filename);
fni:=fni+1;
if fni>15 THEN
fni:=11;
fns:=inttostr(fni);
filename:=fns;
re1.Lines.LoadFromFile('soal/'+filename+'.rt
f');
jss:=inttostr(js);
ket1.Caption:='Jumlah Soal: ' +jss;
if ket1.Caption='Jumlah Soal: 5' then
next.Enabled:=false;
end;
procedure TForm1.AClick(Sender: TObject);
begin
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
if filename='11' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
47
ket2.Caption:='Jumlah Benar:
end else if filename='12' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='13' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='14' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
end else if filename='15' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar:
next.Visible:=false;
end;
end;
'+jbs;
'+jbs;
'+jbs;
'+jbs;
'+jbs;
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
x:=-1;
re1.clear;
timer.Enabled:=false;
waktu.caption:='400';
jb:=0;
js:=0;
end;
end;
procedure TForm1.DClick(Sender: TObject);
begin
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
d.Enabled:=false;
if filename='11' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='12' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='13' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='14' then
begin
edit1.Text:='Benar';
51
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='15' then
begin
edit1.Text:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
next.Visible:=false;
end;
end;
end.
52