Top Banner
Aplikasi Konverter bilangan Biner ke decimal dan hexa decimal Aplikasi ini berguna untuk mengubah data biner 8 bit ke dalam bentuk lain yakni decimal dan hexadecimal, Aplikasi ini dipergunakan untuk mempermudah konversi bilangan biner untuk ditulis (write) ke Port parallel yang tidak memungkinkan untuk menulis data dalam format tipe bit, data yang dapat di tulis ke Port Paralel adalah data bertipe Byte,Word, serta DWord. Untuk dapat membuat Aplikasi Konverter bilangan Biner ke decimal dan hexa decimal, masukkan komponen di dalam tabel berikut ini ke dalam Form1: Tabel . Daftar komponen Aplikasi Konverter bilangan Biner ke decimal dan hexa decimal
16

Aplikasi Konverter Bilangan Biner Ke Decimal Dan Hexa Decimal

Nov 28, 2014

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Aplikasi Konverter Bilangan Biner Ke Decimal Dan Hexa Decimal

Aplikasi Konverter bilangan Biner ke decimal dan hexa decimal

Aplikasi ini berguna untuk mengubah data biner 8 bit ke dalam bentuk lain yakni decimal dan hexadecimal, Aplikasi ini dipergunakan untuk mempermudah konversi bilangan biner untuk ditulis (write) ke Port parallel yang tidak memungkinkan untuk menulis data dalam format tipe bit, data yang dapat di tulis ke Port Paralel adalah data bertipe Byte,Word, serta DWord.

Untuk dapat membuat Aplikasi Konverter bilangan Biner ke decimal dan hexa decimal, masukkan komponen di dalam tabel berikut ini ke dalam Form1:

Tabel . Daftar komponen Aplikasi Konverter bilangan Biner ke decimal dan hexa decimal

Page 2: Aplikasi Konverter Bilangan Biner Ke Decimal Dan Hexa Decimal

Setelah itu susun tampilan menjadi :

No Komponen Properti Nilai

Form1 Caption BINER TO DEC

AND HEXA

GroupBox1 Caption BINER

GroupBox1 Caption Hexa + Decimal

Label1 Caption D0

Label2 Caption D1

Label3 Caption D2

Label4 Caption D3

Label5 Caption D4

Label6 Caption D5

Label7 Caption D6

Label8 Caption D7

Label9 Caption Hexa

Label10 Caption Decimal

Edit1 Text 1

Edit2 Text 1

Edit3 Text 1

Edit4 Text 1

Edit5 Text 1

Edit6 Text 1

Edit7 Text 1

Edit8 Text 1

Edit9 Text Kosongkan

Edit10 Text Kosongkan

Button1 Caption Low

Button2 Caption Low

Button3 Caption Low

Button4 Caption Low

Button5 Caption Low

Button6 Caption Low

Page 3: Aplikasi Konverter Bilangan Biner Ke Decimal Dan Hexa Decimal

Gambar. Desain Tampilan Aplikasi Konverter bilangan Biner ke decimal dan hexa decimal

Setelah selesai penyusunan desain tampilan Aplikasi Konverter bilangan Biner ke decimal dan hexa decimal, deklarasikan sebuah variable global dengan nama value dengan tipe integer sebagai mana gambar di bawah ini :

Gambar . Deklarasi variable Global.

ketikkan Source Code sesuai dengan tabel di bawah ini:

Tabel. Source Code Aplikasi Konverter bilangan Biner ke decimal dan hexa decimal

Nama

Komponen

Event SOURCE CODE

Button1 OnClick value:=strtoint(edit1.Text);

if value = 1 then

begin

value:=0;

button1.Caption:='High';

edit1.Text:=inttostr(value);

end

else

if value = 0 then

Page 4: Aplikasi Konverter Bilangan Biner Ke Decimal Dan Hexa Decimal

begin

value:=1;

edit1.Text:=inttostr(value);

button1.Caption:='Low';

end;

Button2 OnClick value:=strtoint(edit2.Text);

if value = 1 then

begin

value:=0;

button2.Caption:='High';

edit2.Text:=inttostr(value);

end

else

if value = 0 then

begin

value:=1;

edit2.Text:=inttostr(value);

button2.Caption:='Low';

end;

Button3 OnClick value:=strtoint(edit3.Text);

if value = 1 then

begin

value:=0;

button3.Caption:='High';

edit3.Text:=inttostr(value);

end

Page 5: Aplikasi Konverter Bilangan Biner Ke Decimal Dan Hexa Decimal

else

if value = 0 then

begin

value:=1;

edit3.Text:=inttostr(value);

button3.Caption:='Low';

end;

Button4 OnClick value:=strtoint(edit4.Text);

if value = 1 then

begin

value:=0;

button4.Caption:='High';

edit4.Text:=inttostr(value);

end

else

if value = 0 then

begin

value:=1;

edit4.Text:=inttostr(value);

button4.Caption:='Low';

end;

Button5 OnClick value:=strtoint(edit5.Text);

if value = 1 then

begin

value:=0;

button5.Caption:='High';

Page 6: Aplikasi Konverter Bilangan Biner Ke Decimal Dan Hexa Decimal

edit5.Text:=inttostr(value);

end

else

if value = 0 then

begin

value:=1;

edit5.Text:=inttostr(value);

button5.Caption:='Low';

end;

Button6 OnClick value:=strtoint(edit6.Text);

if value = 1 then

begin

value:=0;

button6.Caption:='High';

edit6.Text:=inttostr(value);

end

else

if value = 0 then

begin

value:=1;

edit6.Text:=inttostr(value);

button6.Caption:='Low';

end;

Button7 OnClick value:=strtoint(edit7.Text);

if value = 1 then

begin

Page 7: Aplikasi Konverter Bilangan Biner Ke Decimal Dan Hexa Decimal

value:=0;

button7.Caption:='High';

edit7.Text:=inttostr(value);

end

else

if value = 0 then

begin

value:=1;

edit7.Text:=inttostr(value);

button7.Caption:='Low';

end;

Button8 OnClick value:=strtoint(edit8.Text);

if value = 1 then

begin

value:=0;

button8.Caption:='High';

edit8.Text:=inttostr(value);

end

else

if value = 0 then

begin

value:=1;

edit8.Text:=inttostr(value);

button8.Caption:='Low';

end;

Button9 OnClick var

Page 8: Aplikasi Konverter Bilangan Biner Ke Decimal Dan Hexa Decimal

bit1,bit2,bit3,bit4,bit5,bit6,bit7,bit8,d

ec1,dec2,dec3,dec4,dec5,dec6,dec7,d

ec8,dec_tot:integer;

begin

bit1:= strtoint(Edit1.text);

if bit1=0 then dec1:=0 else

dec1:=1;

bit2:= strtoint(Edit2.text);

if bit2=0 then dec2:=0 else dec2:=2;

bit3:= strtoint(Edit3.text);

if bit3=0 then dec3:=0 else

dec3:=4;

bit4:= strtoint(Edit4.text);

if bit4=0 then dec4:=0 else

dec4:=8;

bit5:= strtoint(Edit5.text);

if bit5=0 then dec5:=0 else

dec5:=16;

bit6:= strtoint(Edit6.text);

if bit6=0 then dec6:=0 else

dec6:=32;

bit7:= strtoint(Edit7.text);

if bit7=0 then dec7:=0 else

dec7:=64;

bit8:= strtoint(Edit8.text);

if bit8=0 then dec8:=0 else

Page 9: Aplikasi Konverter Bilangan Biner Ke Decimal Dan Hexa Decimal

dec8:=128;

dec_tot:=dec1+dec2+dec3+dec4+de

c5+dec6+dec7+dec8;

edit10.Text:=inttostr(dec_tot);

Button10 OnClick var str1,str2,hexa : string;

begin

str1 :=Edit4.Text + Edit3.Text +

Edit2.Text + Edit1.Text;

if (str1 = '0000')then hexa :='0';

if (str1 = '0001')then hexa :='1';

if (str1 = '0010')then hexa :='2';

if (str1 = '0011')then hexa :='3';

if (str1 = '0100')then hexa :='4';

if (str1 = '0101')then hexa :='5';

if (str1 = '0110')then hexa :='6';

if (str1 = '0111')then hexa :='7';

if (str1 = '1000')then hexa :='8';

if (str1 = '1001')then hexa :='9';

if (str1 = '1010')then hexa :='A';

if (str1 = '1011')then hexa :='B';

if (str1 = '1100')then hexa :='C';

if (str1 = '1101')then hexa :='D';

if (str1 = '1110')then hexa :='E';

if (str1 = '1111')then hexa :='F';

str2 := Edit8.Text + Edit7.Text +

Page 10: Aplikasi Konverter Bilangan Biner Ke Decimal Dan Hexa Decimal

Edit6.Text + Edit5.Text ;

if (str2 = '0000')then

hexa :='0'+hexa;

if (str2 = '0001')then

hexa :='1'+hexa;

if (str2 = '0010')then

hexa :='2'+hexa;

if (str2 = '0011')then

hexa :='3'+hexa;

if (str2 = '0100')then

hexa :='4'+hexa;

if (str2 = '0101')then

hexa :='5'+hexa;

if (str2 = '0110')then

hexa :='6'+hexa;

if (str2 = '0111')then

hexa :='7'+hexa;

if (str2 = '1000')then

hexa :='8'+hexa;

if (str2 = '1001')then

hexa :='9'+hexa;

if (str2 = '1010')then

hexa :='A'+hexa;

if (str2 = '1011')then

hexa :='B'+hexa;

if (str2 = '1100')then

Page 11: Aplikasi Konverter Bilangan Biner Ke Decimal Dan Hexa Decimal

hexa :='C'+hexa;

if (str2 = '1101')then

hexa :='D'+hexa;

if (str2 = '1110')then

hexa :='E'+hexa;

if (str2 = '1111')then

hexa :='F'+hexa;

Edit9.text :=hexa;

end;

Setelah itu lakukan eksekusi/run, berikut ini adalah tampilan pengujian Aplikasi Konverter bilangan Biner ke decimal dan hexa decimal yang dibuat:

Gambar. Konversi biner ke Hexa decimal

Page 12: Aplikasi Konverter Bilangan Biner Ke Decimal Dan Hexa Decimal

Gambar. Konversi biner ke decimal