Laporan Akhir Lab TI Algoritma dan Pemrograman (AP 2A) Pertemuan 5 Pengenalan pada DELPHI
LISTING PROGRAM:
Form untuk login
unit login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses nilai;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if (edit1.text='sutri')and(edit2.Text='12345') then
begin
Form2.Show;
Form1.Hide
end
else
begin
application.messagebox('ID Atau Password Salah',0);
end
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
application.Terminate
end;
end.
Form untuk nilai
unit nilai;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: 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
Form2: TForm2;
implementation
uses login;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
var
a:integer;
begin
a:=strtoint(edit1.Text);
if (a>=0)and(a<=30)then
begin
edit1.font.color:=clred;
edit2.font.color:=clred;
edit3.font.color:=clred;
edit2.Text:='E';
edit3.Text:='Tidak Lulus';
end
else if (a>30)and(a<=40)then
begin
edit1.font.color:=clred;
edit2.font.color:=clred;
edit3.font.color:=clred;
edit2.Text:='D';
edit3.Text:='Tidak Lulus';
end
else if (a>40)and(a<=50)then
begin
edit1.font.color:=clblue;
edit2.font.color:=clblue;
edit3.font.color:=clblue;
edit2.Text:='C';
edit3.Text:='Lulus';
end
else if (a>50)and(a<=75)then
begin
edit1.font.color:=clblue;
edit2.font.color:=clblue;
edit3.font.color:=clblue;
edit2.Text:='B';
edit3.Text:='Lulus';
end
else if (a>75)and(a<=100)then
begin
edit1.font.color:=clblue;
edit2.font.color:=clblue;
edit3.font.color:=clblue;
edit2.Text:='A';
edit3.Text:='Lulus';
end
else
begin
application.messagebox('Data tidak valid',0);
end
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
Form1.Show;
Form2.Hide;
end;
end.
LOGIKA PROGRAM:
Form Login
procedure TForm1.Button1Click(Sender: TObject);
begin
if (edit1.text='sutri')and(edit2.Text='12345') then
begin
form2.show;
form1.Hide
end
else
begin
application.messagebox('ID Atau Password Salah',0);
end
end;
Script diatas digunakan jika text pada edit1 ‘sutri’ dan pada password ‘12345’ maka form2 akan muncul dan form1 akan disembunyikan dan jika salah memasukan password maka akan tampil pesan “ID Atau Password Salah”
procedure TForm1.Button2Click(Sender: TObject);
begin
application.Terminate
end;
end.
Script diatas berfungsi jika button Exit di klik maka Form1 akan keluar atau exit
Form Nilai
procedure TForm2.Button1Click(Sender: TObject);
var
a:integer;
begin
a:=strtoint(edit1.Text);
if (a>=0)and(a<=30)then
begin
edit1.font.color:=clred;
edit2.font.color:=clred;
edit3.font.color:=clred;
edit2.Text:='E';
edit3.Text:='Tidak Lulus';
end
else if (a>30)and(a<=40)then
begin
edit1.font.color:=clred;
edit2.font.color:=clred;
edit3.font.color:=clred;
edit2.Text:='D';
edit3.Text:='Tidak Lulus';
end
else if (a>40)and(a<=50)then
begin
edit1.font.color:=clblue;
edit2.font.color:=clblue;
edit3.font.color:=clblue;
edit2.Text:='C';
edit3.Text:='Lulus';
end
else if (a>50)and(a<=75)then
begin
edit1.font.color:=clblue;
edit2.font.color:=clblue;
edit3.font.color:=clblue;
edit2.Text:='B';
edit3.Text:='Lulus';
end
else if (a>75)and(a<=100)then
begin
edit1.font.color:=clblue;
edit2.font.color:=clblue;
edit3.font.color:=clblue;
edit2.Text:='A';
edit3.Text:='Lulus';
end
else
begin
application.messagebox('Data tidak valid',0);
end
end;
Script diatas berfungsi Jika text pada edit1 diberikn nilai 0>30 maka edit2 akan memberikan E dan edit3 Tidak lulus,30>40 maka edit2 akan memberikan D dan edit3 Tidak lulus,40>50 maka edit2 akan memberikan C dan edit3 lulus,50>75 maka edit2 akan memberikan B dan edit3 lulus,75>100 maka edit2 akan memberikan A dan edit3 lulus dan jika salah input akan tampil pesan “Data tidak valid”
procedure TForm2.Button3Click(Sender: TObject);
begin
form1.Show;
form2.Hide;
end;
Script diatas berfungsi jika button Exit di klik maka form1 akan muncul dan form2 akan disembunyikan
procedure TForm2.Button3Click(Sender: TObject);
begin
edit1.Text:='';
edit2.Text:='';
edit3.Text:='';
end;
end.
Script diatas berfungsi jika button Clear di klik maka edit1.text,edit2.text dan edit3.text akan dihapus
OUTPUT PROGRAM:
Belum ada Komentar untuk "Laporan Akhir Lab TI Algoritma dan Pemrograman (AP 2A) Pertemuan 5 Pengenalan pada DELPHI"
Posting Komentar