Reques dari temen untuk bikinin
contoh if sederhana menggunakan Dhelphi 7. Langsung saja
- Buatlah Form seperti dibawah ini:
unit tugas1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
GroupBox1: TGroupBox;
Label3: TLabel;
txtnim: TEdit;
txtnama: TEdit;
Label2: TLabel;
Label4: TLabel;
txtnilai: TEdit;
Label5: TLabel;
txthasil: TEdit;
Label6: TLabel;
cbopilih: TComboBox;
GroupBox2: TGroupBox;
btnexit: TButton;
btncount: TButton;
procedure btncountClick(Sender: TObject);
procedure btnexitClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
nilai:Integer;
implementation
{$R *.dfm}
'perintah ketika Button count diklik
procedure TForm1.btncountClick(Sender: TObject);
begin
nilai:=StrToInt(txtnilai.Text);
if nilai>80 then
txthasil.Text:='Anda Masuk Grade A'
else
if nilai>60 then
txthasil.Text:='Anda Masuk Grade B'
else
if nilai>50 then
txthasil.Text:='Anda Masuk Grade C'
else
txthasil.Text:='Anda Tidak Lulus';
end;
procedure TForm1.btnexitClick(Sender: TObject);
begin
Close;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
GroupBox1: TGroupBox;
Label3: TLabel;
txtnim: TEdit;
txtnama: TEdit;
Label2: TLabel;
Label4: TLabel;
txtnilai: TEdit;
Label5: TLabel;
txthasil: TEdit;
Label6: TLabel;
cbopilih: TComboBox;
GroupBox2: TGroupBox;
btnexit: TButton;
btncount: TButton;
procedure btncountClick(Sender: TObject);
procedure btnexitClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
nilai:Integer;
implementation
{$R *.dfm}
'perintah ketika Button count diklik
procedure TForm1.btncountClick(Sender: TObject);
begin
nilai:=StrToInt(txtnilai.Text);
if nilai>80 then
txthasil.Text:='Anda Masuk Grade A'
else
if nilai>60 then
txthasil.Text:='Anda Masuk Grade B'
else
if nilai>50 then
txthasil.Text:='Anda Masuk Grade C'
else
txthasil.Text:='Anda Tidak Lulus';
end;
procedure TForm1.btnexitClick(Sender: TObject);
begin
Close;
end;
end.
- jika program dijalankan tampilanya akan seperti ini:
- Dan ini :
Sampai disini dulu selamat mencoba semoga bermanfaat.



0 komentar:
Posting Komentar