Embarcadero/Borland Delphi Programming Language If-Then Example
This is the easiest way to implement events and properties in Delphi.
Note:
Kalkulator Sederhana = Simple Calculator
Nilai = Value
Hasil = result
Tambah = Add
Kurang = Substract
Kali = Multiplication
Bagi = Division
Form design:
Properties:
Components
|
Properties
|
Value
|
Form |
Caption |
Program 2 Pemilihan |
|
Width |
266 |
|
Height |
221 |
Label1 |
Caption |
Kalkulator Sederhana |
Label2 |
Caption |
Nilai X |
Label3 |
Caption |
Nilai Y |
Label4 |
Caption |
Operator |
Label5 |
Caption |
Output |
Edit1 |
Text |
Kosongkan |
Edit2 |
Text |
Kosongkan |
Edit3 |
Text |
Kosongkan |
ComboBox1 |
Caption |
Tambah |
|
Items |
Tambah Kurang Kali Bagi |
Delphi program:
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
if ComboBox1.Text = 'Tambah' then
Begin
Edit3.Text := IntToStr(StrToInt(Edit1.Text) + StrToInt(Edit2.Text));
End;
if ComboBox1.Text = 'Kurang' then
Begin
Edit3.Text := IntToStr(StrToInt(Edit1.Text) - StrToInt(Edit2.Text));
End;
if ComboBox1.Text = 'Kali' then
Begin
Edit3.Text := IntToStr(StrToInt(Edit1.Text) * StrToInt(Edit2.Text));
End;
if ComboBox1.Text = 'Bagi' then
Begin
Edit3.Text := IntToStr(StrToInt(Edit1.Text) div StrToInt(Edit2.Text));
End;
end;
Output:
ShadowOfBdg© - All rights reserved.
No comments:
Post a Comment