Jumat, 18 Oktober 2013
MEMBUAT APLIKASI FORM SEDERHANA DENGAN DELPHI 7
unit uform;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls, Menus, Buttons;
type
TForm1 = class(TForm)
Label1: TLabel;
edNBI: TEdit;
Label2: TLabel;
edNama: TEdit;
Label3: TLabel;
edAlamat: TEdit;
cbJurusan: TComboBox;
Label4: TLabel;
rgKelamin: TRadioGroup;
hobby1: TCheckBox;
Label5: TLabel;
hobby2: TCheckBox;
hobby3: TCheckBox;
hobby4: TCheckBox;
btProses: TButton;
btReset: TButton;
btIF: TButton;
btFor: TButton;
btWhile: TButton;
btRepeat: TButton;
btCase: TButton;
btPesan: TButton;
MainMenu1: TMainMenu;
FILE1: TMenuItem;
PROSES1: TMenuItem;
RESET1: TMenuItem;
ACTION1: TMenuItem;
btIF1: TMenuItem;
btFor1: TMenuItem;
bt1: TMenuItem;
btRepeat1: TMenuItem;
HELP1: TMenuItem;
btCase1: TMenuItem;
Image1: TImage;
memo1: TMemo;
Label6: TLabel;
BitBtn1: TBitBtn;
procedure btCaseClick(Sender: TObject);
procedure btIFClick(Sender: TObject);
procedure btForClick(Sender: TObject);
procedure btWhileClick(Sender: TObject);
procedure btRepeatClick(Sender: TObject);
procedure btPesanClick(Sender: TObject);
procedure btProsesClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btCaseClick(Sender: TObject);
var i, bil : integer;
begin
//pengganti if
bil := StrToInt(edNBI.Text);
case bil of
1 : edNama.Text := 'Bilangan = 1 ';
2 : edNama.Text := 'Bilangan = 2 ';
3 : edNama.Text := 'Bilangan = 3 ';
4 : edNama.Text := 'Bilangan = 4 ';
end;
end;
procedure TForm1.btIFClick(Sender: TObject);
var bil : integer;
begin
//end sebelum else , harus tanpa titik koma
bil := StrToInt(edNBI.Text);
if bil < 10 then
begin
edNama.Text := 'Bilangan kurang dari 10';
end
else
begin
edNama.Text := 'Bilangan lebih dari sama dengan 10';
end;
end;
procedure TForm1.btForClick(Sender: TObject);
var i, bil : integer;
begin
bil := StrToInt(edNBI.Text);
for i := 0 to bil - 1 do
begin
memo1.Lines.Add('looping ke ' + intToStr(i)) ;
end;
end;
procedure TForm1.btWhileClick(Sender: TObject);
var i, bil : integer;
begin
bil := StrToInt(edNBI.Text);
i := 0;
while i < bil do
begin
memo1.Lines.Add('looping ke ' + intToStr(i)) ;
i := i+1;
end ;
end;
procedure TForm1.btRepeatClick(Sender: TObject);
var i, bil : integer;
begin
bil := StrToInt(edNBI.Text);
i := 0;
repeat
memo1.Lines.Add('looping ke ' + intToStr(i)) ;
i := i+1;
until i>bil ;
end;
procedure TForm1.btPesanClick(Sender: TObject);
begin
ShowMessage('Haloo Aku Informatika');
end;
procedure TForm1.btProsesClick(Sender: TObject);
begin
memo1.Lines.Add('NBI = ' + edNBI.Text);
memo1.Lines.Add('Nama = ' + edNama.Text);
memo1.Lines.Add('Alamat =' + edAlamat.Text);
memo1.Lines.Add('Kelamin = ' + rgKelamin.Items[rgKelamin.ItemIndex]);
memo1.Lines.Add('Jurusan = ' + cbJurusan.Items[cbJurusan.ItemIndex]);
memo1.Lines.Add('No Jurusan = ' + intToStr(cbJurusan.ItemIndex) );
//cbJurusan.Items[0] = 'teknik industri'
//cbJurusan.Items[1] = 'teknik mesin'
//cbJurusan.Items[2] = 'teknik sipil'
//cbJurusan.Items[3] = 'teknik informatika'
if (hobby1.Checked=true) then
memo1.Lines.Add(hobby1.Caption);
if (hobby2.Checked=true) then
memo1.Lines.Add(hobby2.Caption);
if (hobby3.Checked=true) then
memo1.Lines.Add(hobby3.Caption);
if (hobby4.Checked=true) then
memo1.Lines.Add(hobby4.Caption);
//ShowMessage(BoolToStr(cbHobi1.Checked));
end;
end.
Langganan:
Posting Komentar (Atom)
apik lay..blog e
BalasHapus