You are on page 1of 51

1

LATIHAN 1



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;
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;

2
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:='';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
application.Terminate;
end;
end.
3
LATIHAN 2



unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Label4: TLabel;
Label5: TLabel;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
4
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button5Click(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
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';
5
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';
end;
end.

6
LATIHAN 3



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;
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';
7
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.
8
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);
9
procedure ComboBox1Change(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Edit1Change(Sender: TObject);
begin
label6.Caption:=edit1.Text;
end;
procedure TForm1.Edit2Change(Sender: TObject);
begin
label7.Caption:=edit2.Text;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
label8.Caption:=combobox1.Text;
end;
procedure TForm1.ListBox1Click(Sender: TObject);
begin
label9.Caption:=listbox1.Items[listbox1.itemindex];
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.text:='';
Edit2.text:='';
10
Label6.caption:='';
Label7.caption:='';
Label8.caption:='';
Label9.caption:='';
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;
12
Button3: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if ck1.Checked or ck2.Checked or ck3.Checked or
ck4.Checked
then memo1.Lines.add(groupbox1.Caption);
if ck1.Checked then memo1.Lines.add(ck1.Caption);
if ck2.Checked then memo1.Lines.add(ck2.Caption);
if ck3.Checked then memo1.Lines.add(ck3.Caption);
if ck4.Checked then memo1.Lines.add(ck4.Caption);
memo1.lines.add('');
if ck5.Checked or ck6.Checked or ck7.Checked or
ck8.Checked or ck9.Checked or ck10.Checked or
ck11.Checked or ck12.Checked then
memo1.Lines.add(groupbox2.Caption);
if ck5.Checked then memo1.Lines.add(ck5.Caption);
if ck6.Checked then memo1.Lines.add(ck6.Caption);
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);
13
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('c:/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('c:/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:/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;
17
implementation
{$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;
18
edit3.Text:=floattostr(c);
end else if rg1.ItemIndex=1 then
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:='';
19
end;
end.













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);
procedure Button3Click(Sender: TObject);
21
procedure Panel1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit1, Unit3;
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
begin
richedit1.Visible:=false;
image1.Visible:=true;
image1.Picture.loadfromfile('c:/a.jpg');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
richedit1.Visible:=true;
image1.Visible:=false;
richedit1.lines.loadfromfile('c:/a.rtf');
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if messagedlg ('Anda yakin Akan Keluar ?',
mtConfirmation,mbOkCancel,0)
=mrOk then
Application.Terminate;
end;
procedure TForm1.Panel1Click(Sender: TObject);
begin
Aboutbox.ShowModal;
end;
end.


22
unit Unit3;
interface
uses
Windows, SysUtils, Classes, Graphics, Forms, 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.












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 }
24
public
{ Public declarations }
end;
var
Form1: TForm1;
n,a,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);
a:=(n*R*T);
p:=a/v;
label5.Caption:=floattostr(p);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.text:='';
edit2.text:='';
edit3.text:='';
label5.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}
26
procedure TForm1.Button2Click(Sender: TObject);
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
28
{ Public declarations }
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
30
{ Private declarations }
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;

31
procedure TForm1.Button3Click(Sender: TObject);
begin
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;
33
Label17: TLabel;
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-';
34
label14.Caption:=floattostr(c) + ' liter larutan
mengandung ' + floattostr(d) + ' mol Ag+';
label15.Caption:='Volume campuran = ' + floattostr(e) +
' liter';
label16.Caption:='[Cl-] = ' + floattostr(b) + '/' +
floattostr(e) + ' mol/liter = ' + floattostr(f) + ' mol/liter';
label17.Caption:='[Ag+] = ' + floattostr(d) + '/' +
floattostr(e) + ' mol/liter = ' + floattostr(g) + ' mol/liter';
label18.Caption:='[Ag+][Cl-] = ' + floattostr(f) + ' x ' +
floattostr(g) + ' = ' + floattostr(h);
if h < ksp then
begin
label19.Caption:='Karena [Ag+][Cl-] < Ksp maka
AgCl tidak mengendap';
end else
label19.Caption:='Karena [Ag+][Cl-] > Ksp maka
AgCl mengendap';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
application.Terminate;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
edit4.Text:='';
label13.Caption:='';
label14.Caption:='';
label15.Caption:='';
label16.Caption:='';
label17.Caption:='';
label18.Caption:='';
label19.Caption:='';
end;
end.
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);
procedure Button2Click(Sender: TObject);
36
private
{ Private declarations }
public
{ Public declarations }
end;
Var
Form1: TForm1;
implementation
uses Unit2, Ugab2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
application.Terminate;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
button1.Enabled:=false;
button2.Enabled:=false;
end;
procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
if radiogroup1.ItemIndex=0 then
begin
button1.Enabled:=true;
button2.Enabled:=true;
end else if radiogroup1.ItemIndex=1 then
begin
button1.Enabled:=true;
button2.Enabled:=false;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
form1.Visible:=false;
form2.visible:=true;
end;
end.
37
unit Ugab2;
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}

38
procedure TForm2.Button1Click(Sender: TObject);
begin
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);
41
procedure FormCreate(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
button4.Visible:=false;
panel1.Visible:=false;
image1.Visible:=false;
image2.Visible:=false;
richedit1.Visible:=true;
richedit1.Lines.LoadFromFile('Data/tulisan.rtf');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
button4.Visible:=false;
panel1.Visible:=false;
image1.Visible:=true;
image2.Visible:=false;
richedit1.Visible:=false;
image1.picture.LoadFromFile('Data/gambar.jpg');
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
button1.Enabled:=false;
button2.Enabled:=false;
button3.Enabled:=false;
button4.Visible:=true;
panel1.Visible:=false;
42
image1.Visible:=false;
image2.Visible:=false;
richedit1.Visible:=false;
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;
44
Mulai: TButton;
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
45
IF messagedlg ('Anda yakin Akan Keluar ?',
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');
46
js:=1;
jss:=inttostr(js);
ket1.Caption:='Jumlah Soal : '+jss;
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+'.rtf');
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
47
begin
edit1.Text:='Benar';
jb:=jb+1;
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:='Salah';
jb:=jb;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='15' then
begin
edit1.Text:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
next.Visible:=false;
end;
end;
procedure TForm1.BClick(Sender: TObject);
begin
a.Enabled:=false;
b.Enabled:=false;
c.Enabled:=false;
48
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:='Benar';
jb:=jb+1;
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:='Salah';
jb:=jb;
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;
procedure TForm1.CClick(Sender: TObject);
begin
a.Enabled:=false;
49
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:='Benar';
jb:=jb+1;
jbs:=inttostr(jb);
ket2.Caption:='Jumlah Benar: '+jbs;
end else if filename='14' then
begin
edit1.Text:='Salah';
jb:=jb;
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;

50
procedure TForm1.TimerTimer(Sender: TObject);
begin
x:=x+2;
xs:=inttostr(400-x);
waktu.Caption:=xs+' detik';
xb:=strtoint(xs);
if xb=0 then
begin
mulai.Enabled:=true;
next.Enabled:=false;
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';
51
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';
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.