Contoh Program Delphi untuk menghitung bilangan biner ke desimal



Hay teman-teman semua pada kesempatan saya akan membagikan bagaimana cara membuat program untuk menghitung bilangan biner ke bilangan desimal

  1. Bukalah delphi . Di sini saya menggunakan delphi versi 7 
  2. Lalu gunakanlah komponen sebagai berikut.
  3. Edit sebanyak 5
    Button 1
    Label 2 
    Lalu aturlah sesuai keinginan anda
       

    3. Klik 2 kali pada komponen button lalu masukan coding seperti berikut 
 unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
type
  TForm1 = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Label2: TLabel;
    Edit3: TEdit;
    Edit4: TEdit;
    Button1: TButton;
    Edit5: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
  a,b,c,d,e : integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
a :=strtoint(edit1.Text);
b :=strtoint(edit2.Text);
c :=strtoint(edit3.Text);
d :=strtoint(edit4.Text);
//digit 1
if a=1 then
begin
 a:=1;
end
else if a=0 then
begin
 a:=0;
end
else
begin
 application.MessageBox('Harus Bilangan Biner','INGAT !!!',mb_ok)
end;
//digit 2
if b=1 then
begin
 b:=2;
end
else if b=0 then
begin
 b:=0
end
else
begin
 application.MessageBox('Harus Bilangan Biner','INGAT !!!',mb_ok)
end;
//digit3
if c=1 then
begin
 c:=4;
end
else if c=0 then
begin
 c:=0;
end
else
begin
 application.MessageBox('Harus Bilangan Biner','INGAT !!!',mb_ok)
end;
//digit4
if d=1 then
begin
 d:=8
end
else if d=0 then
begin
 d:=0
end
else
begin
 application.MessageBox('Harus Bilangan Biner','INGAT !!!',mb_ok)
end;
  e:=a+b+c+d;
  edit5.Text:=inttostr(e);
end;
end.
 Maka Beginilah Hasilnya 

 Jika anda ingin mendownload Programnya maka kliknya disini 
Sekian dan Trimakasih GBU


Comments

Popular Posts