Minggu, 30 Januari 2011
Contoh dan Coding Calculator simple
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Edit2: TEdit;
Button1: TButton;
Edit3: TEdit;
Button2: TButton;
Button3: TButton;
Edit4: TEdit;
Label2: TLabel;
Edit5: TEdit;
Button4: TButton;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Button5: TButton;
Label3: TLabel;
Edit10: TEdit;
Edit11: TEdit;
Edit12: TEdit;
Button6: TButton;
Label4: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var hasil : integer;
begin
hasil := strtoint (edit1.Text) + strtoint (edit2.Text);
edit3.Text := inttostr (hasil);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Edit1.Text :='';
Edit2.Text :='';
Edit3.Text :='';
Edit4.Text :='';
Edit5.Text :='';
Edit6.Text :='';
Edit7.Text :='';
Edit8.Text :='';
Edit9.Text :='';
Edit10.Text :='';
Edit11.Text :='';
Edit12.Text :='';
end;
procedure TForm1.Button4Click(Sender: TObject);
var hasil : integer;
begin
hasil := strtoint (edit4.Text) - strtoint (edit5.Text);
edit6.Text := inttostr (hasil);
end;
procedure TForm1.Button5Click(Sender: TObject);
var hasil : integer;
begin
hasil := strtoint (edit7.Text) * strtoint (edit8.Text);
edit9.Text := inttostr (hasil);
end;
procedure TForm1.Button6Click(Sender: TObject);
var hasil : double;
begin
hasil := strtoFloat (edit10.Text) / strtoFloat (edit11.Text);
edit12.Text := Floattostr (hasil);
end;
end.
Kursus Komputer Kantor di Palcomtech- Operator dan Type data
Operator dan Type data
1. Operator aritmatika
Type Data
1. Operator aritmatika
- Tambah : + (plus)
- Kurang : - (minus)
- Kali : *(bintang)
- Bagi : / (garis miring)
- Pangkat : ^
- Lebih dari = >
- Kurang dari = <
- Lebih dari sama dengan = >=
- Kurang dari sama dengan = <=
Type Data
- untuk teks => (string, Char)
- untuk number => (VarChar,double,single)
- untuk boleaan => (Or,Xor,Not,And)
- Int to Str : mengubah bil. bulat ke string
- Int to float : mengubah bil. bulat ke decimal
- Float to Int : mengubah decimal ke bil. bulat
- Float to Str : mengubah decimal ke string
- Str to Int mengubah bil String to Int
Label:
Float to Str,
Int to Str,
Operator,
Type data
Langganan:
Postingan (Atom)