buat temen-temen yang masih bingung buat tugas delphinya , nih ane upload tutornya buat kalian temen-temen tercinta hahahahahahahahahahahhaha. Langsung ke pokok permasalahannya ya, Pertama-tama buat form seperti diatas ( name propertiesnya ada digambar ya, yang warna merah), kalo udah silahkan buat kodingnya seperti yang dibawah ini, cekidot
==========================================================================unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
GroupBox1: TGroupBox;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
GroupBox2: TGroupBox;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
Label6: TLabel;
Label7: TLabel;
GroupBox3: TGroupBox;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Label8: TLabel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
Label9: TLabel;
Label10: TLabel;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure Button3Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
procedure CheckBox2Click(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if key= chr(13) then
begin
edit3.Text := floattostr(strtofloat(edit1.Text )*40/100);
begin
edit2.SetFocus
end;
end;
end;
procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if key= chr(13) then
begin
edit4.Text := floattostr(strtofloat(edit2.Text )*60/100);
begin
edit5.Text := floattostr(strtofloat(edit3.Text )+ strtofloat(edit4.Text )) ;
begin
if edit5.Text < '60' then
edit6.Text := 'Gagal'
else if edit5.Text >='60' then
edit6.Text := 'Lulus'
end;
end;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if(application.MessageBox('Udah kluar sono!!!','fik0',mb_yesno)=id_yes) then
begin
close;
end;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
if checkbox1.Checked = true then
edit7.Text := '250000'
else if checkbox1.Checked = false then
edit7.Text := ''
end;
procedure TForm1.CheckBox2Click(Sender: TObject);
begin
if checkbox2.Checked = true then
edit8.Text := '300000'
else if checkbox2.Checked = false then
edit8.Text := ''
end;
procedure TForm1.RadioButton1Click(Sender: TObject);
begin
if radiobutton1.Checked = true then
edit9.Text := '500000'
end;
procedure TForm1.RadioButton2Click(Sender: TObject);
begin
if radiobutton2.Checked = true then
edit9.Text := '1000000'
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
edit10.Text := floattostr(strtofloat(edit7.Text )+ strtofloat(edit8.Text )+strtofloat(edit9.Text ));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text := '';
edit2.Text := '';
edit3.Text := '';
edit4.Text := '';
edit5.Text := '';
edit6.Text := '';
edit7.Text := '';
edit8.Text := '';
edit9.Text := '';
edit10.Text := '';
checkbox1.Checked := false;
checkbox2.Checked := false;
radiobutton1.Checked :=false;
radiobutton2.Checked :=false;
end;
end.
==========================================================================
selanjutnya tinggal dicoba sendiri ya di komputer masing-masing. kalo ada pertanyaan silahkan tulis di komen aja,
NB:
Cara buat key press:
gbr keypress |
- fungsi keypress adalah untuk mengaktifkan fungsi enter saat kursor berada di edit box. seperti pada gbr keypress . Tidak seperti di VB6 mengganti fungsi change , keypress dll di delphi 7 ini agak ribet (pendapat pribadi jadi jangan protes) , caranya adalah :
1. Pilih Edit1
2. Lihat di Object Inspector, di sana ada 2 tab ('Properties ' dan ' Event'), lalu kita pilih (klik) Events
3. Cari tulisan OnKeypress disana
4. Klik 2x pada kolom combo tapi kolomnya ya bukan tanda panah kebawahnya
5. selesai
0 komentar:
Post a Comment