Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
OLEH :
AFDAL LUTHFI
18063047
DOSEN PENGAMPU :
FAKULTAS TEKNIK
2020
BAB IV
Struktur Perulangan dan Mengenal Input Inbox
PROGRAM :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
eitem: TEdit;
cmdok: TButton;
Label2: TLabel;
Label3: TLabel;
etgl: TEdit;
enofaktur: TEdit;
GroupBox2: TGroupBox;
GroupBox3: TGroupBox;
lnama: TListBox;
lharga: TListBox;
Label4: TLabel;
etotal: TEdit;
cmdlagi: TButton;
cmdclose: TButton;
procedure cmdokClick(Sender: TObject);
procedure cmdlagiClick(Sender: TObject);
procedure cmdcloseClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
DateSeparator:='-';
ShortDateFormat:='mm/dd/yyyy';
etgl.Text:='Hari Ini' + DateToStr(Date);
end;
end.
4.4. Aplikasi Konversi Suhu
PROGRAM :
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Label1: TLabel;
GroupBox1: TGroupBox;
Label2: TLabel;
Eawal: TEdit;
Label3: TLabel;
Label4: TLabel;
Etambah: TEdit;
Button1: TButton;
GroupBox2: TGroupBox;
Label5: TLabel;
Label6: TLabel;
LBcelcius: TListBox;
LBfarenheit: TListBox;
Button2: TButton;
Eakhir: TEdit;
procedure EawalChange(Sender: TObject);
procedure EakhirChange(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
end.
BAB V
Subrutin (Procedure & Function)
PROGRAM :
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm3 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
function hitung (var x,y : integer):integer;
begin
hitung :=x+y;
end;
PROGRAM :
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm4 = class(TForm)
Label1: TLabel;
GroupBox1: TGroupBox;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Edit2: TEdit;
Label4: TLabel;
Edit3: TEdit;
Label5: TLabel;
Edit4: TEdit;
Label6: TLabel;
Edit5: TEdit;
Label7: TLabel;
Edit6: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
{$R *.dfm}
end.
BAB VI
ARRAY
PROGRAM :
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm5 = class(TForm)
Label1: TLabel;
GroupBox1: TGroupBox;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Edit2: TEdit;
Label4: TLabel;
Button1: TButton;
Edit3: TEdit;
Edit4: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
implementation
{$R *.dfm}
procedure TForm5.Button1Click(Sender: TObject);
type
x=string[7];
const
faktorbln : array [1..12]of byte=(0,3,3,6,1,4,6,2,5,0,3,5);
hari:array[0..8]of
x=('Minggu','Senin','Selasa','','Rabu','Kamis','','Jum''at','Sabtu');
var
hr:string;
nama:string[255];
j1,j2,j3,j4:integer;
tanggal,bulan,tahun:integer;
begin
tanggal:=strtoint(edit1.Text);
bulan:=strtoint(edit2.Text);
tahun:=strtoint(edit3.Text);
if tahun>1900 then tahun := tahun - 1900;
j1:=trunc(tahun*365.25);
j2:=j1 + faktorbln[bulan];
if(tahun/4=int(tahun/4))and(bulan<3)then j2 := j2 - 1;
j3:=j2 + tanggal;
j4:=trunc(frac(j3/7)*10);
hr:=Hari[j4];
edit4.Text:=hr;
end;
end.
BAB VII
Operator String
7.1. Menggabungkan String
PROGRAM :
unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm6 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Edit3: TEdit;
Button1: TButton;
Label4: TLabel;
Edit4: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form6: TForm6;
implementation
{$R *.dfm}
end.
7.2. Menghapus Teks
PROGRAM :
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm7 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
GroupBox1: TGroupBox;
Label3: TLabel;
Edit2: TEdit;
Label4: TLabel;
Edit3: TEdit;
Label5: TLabel;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
implementation
{$R *.dfm}
end;
end.
PROGRAM :
unit Unit8;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm8 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form8: TForm8;
implementation
{$R *.dfm}
procedure TForm8.Button1Click(Sender: TObject);
Var
nama : string;
begin
nama:=edit1.Text;
edit2.Text:=inttostr(length(nama));
end;
end.
PROGRAM :
unit Unit9;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm9 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Edit2: TEdit;
Label4: TLabel;
Edit3: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form9: TForm9;
implementation
{$R *.dfm}
procedure TForm9.Button1Click(Sender: TObject);
Var karakter : String ;
kar : String;
hasil : integer;
begin
karakter:=edit1.Text;
kar:=edit2.Text;
hasil:=pos(kar,karakter);
edit3.Text:=inttostr(hasil);
end;
end.
7.5. Mengkopi String
PROGRAM :
unit Unit10;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm10 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Label3: TLabel;
Edit2: TEdit;
Label4: TLabel;
Edit3: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form10: TForm10;
implementation
{$R *.dfm}
end.