Filed under: Delphi | 5 Comments »
Delphi : Aplikasi Database pada Visual Delphi
Latihan 3. Pemrograman Delphi
Latihan 2. Pemrograman Delphi
Buatlah Form seperti gambar di atas yang terdiri dari label, edit , button dan StrinGrid, Jika setelah selesai double klik pada form atau tepatnya pada gambar titik-titik. Dan buatlah koding sebagai berikut :
procedure TForm2.FormCreate(Sender: TObject); begin SG.RowCount := 0; SG.ColCount := 8; end;
langkah selanjutnya adalah membuat koding pada tombol OK, dengan cara double klik tombol OK lalu ketik Listing program berikut :
procedure TForm2.Button1Click(Sender: TObject); var tot, bobot, i,jumbot : integer; IPK,totsks,totjumbot : real; begin sg.Cells[1,SG.RowCount -1]:= edit3.Text; sg.Cells[2,sg.RowCount -1]:= edit4.Text; sg.Cells[3,sg.RowCount -1]:= edit5.Text; sg.Cells[4,sg.RowCount -1]:= edit6.Text; if edit6.Text = 'A' then Bobot := 4 else if edit6.Text = 'B' then Bobot := 3 else if edit6.Text = 'C' then Bobot := 2 else Bobot := 1; jumbot := bobot * strtoint(edit5.Text); sg.Cells[5,sg.RowCount -1]:= inttostr(bobot); sg.Cells[6,sg.RowCount -1]:= inttostr(jumbot); for i := 0 to sg.rowcount-1 do begin totjumbot := totjumbot + strtoint(sg.Cells[6,i]); totsks := totsks + strtoint(sg.Cells[3,i]); sg.Cells[0,i] := inttostr(i+1); end; IPK := totjumbot/totsks; edit7.Text :=floattostrf(IPK); sg.RowCount := sg.RowCount + 1; end; end.
Materi yang berhubungan :
Filed under: Delphi | 2 Comments »
Latihan 1. Pemrograman Delphi
Buatlah Form seperti diatas,
Langkah 1. Setelah selesai membuat form seperti gambar di atas, langkah selanjutnya adalah double klik Combobox1, lalu ketik listing program seperti berikut :
procedure TForm1.ComboBox1Change(Sender: TObject); begin if combobox1.Text = 'II' then Edit3.text := inttostr(10) else if combobox1.Text = 'III' then Edit3.text := inttostr(12) else if combobox1.text ='IV' then Edit3.text := inttostr(14); end;
Langkah 2. Selanjutnya adalah double klik pada edit4, lalu klik Properties klik Event, klik on key press, dan mengetikkan listing koding berikut :
procedure TForm1.Edit4KeyPress(Sender: TObject; var Key: Char); var jumlah : integer; begin if key = #13 then if strtoint(edit4.Text) > strtoint(edit3.Text) then begin jumlah := strtoint(edit4.text) - strtoint(edit3.text); edit5.Text := inttostr(jumlah); end else edit5.Text := inttostr(0); end;
Langkah 3. Double klik pada edit6 rubah dari event change dengan on key press seperti langkah 2, lalu ketik program berikut :
procedure TForm1.Edit6KeyPress(Sender: TObject; var Key: Char); var honor : integer; begin if key = #13 then honor := strtoint(edit5.text) * strtoint(edit6.Text); edit7.Text := inttostr(honor); end;
Materi yang berhubungan :
Filed under: Delphi | 1 Comment »