You are on page 1of 17

Object 1

Binary/Hex/BCD/Octal/Decimal Converter

ey

m an electrical engineer and im just starting to learn vb.. Since i have to do a lott
umber conversions when working with processors/PLCs i thought i might try to
write a program that allows me to convert between all the different number
ystems.. only thing is, i dont really know where to start.. Anyone have any tips? I
now how to convert all the number systems longhand so i know the math behind
, but the programming is just beyond me

ny links or sample code would be nice

hanks

ichie

Edited by - Richie086 on 7/12/2003 3:21:27 PM


--
oogle_ad_client = "pub-3989012142716975";
468x60, big-468 */
oogle_ad_slot = "3379142823";
oogle_ad_width = 468;
oogle_ad_height = 60;
->google_protectAndRun("ads_core.google_render_ad", google_handleError, google_render_ad);
ew Complete Forum Thread with Replies

ee Related Forum Messages: Follow the Links Below to View Complete Thread

• Converting Numbers To Hex, Octal, Binary, And Decimal


• Binary,Decimal,Hexadecimal, Octal Notation...
• Decimal To Binary Converter
• Binary To Decimal Converter?
• Decimal & Octal Numbering Systems...
• Convetring Decimal, Hexadecimal, Octal, ASCII ...
• Binary To Octal---help!!
• Binary Hex And Octal Conversions
• Binary To Octal Convertion
• R: Binary To Octal Convertion
• How Do I Convert An Octal (base 8) Value To A Decimal Value (base 10)
• Binary Converter
• Binary/integer Converter
• Binary To String Converter
• Conversion Binary To Binary And Conversion Of Hexadecimal To Decimal In Calculator
• Decimal To Binary
• Decimal To Binary
• Decimal To Binary
• Binary To Decimal
• Decimal To BInary
• Binary To Decimal
• Binary To Decimal Help!
• Hex/decimal To Binary
• Binary/Hex/Decimal Arithmetic
• Binary/Hex/Decimal Conversions
• Decimal 2 Binary Conversion
• Binary To Decimal And The Reverse
• Binary/Decimal Conversion
• VBA Decimal To Binary Query!
• Convert Decimal To Binary??
• Pseudocode For Binary To Decimal In VB Plz
• Decimal To Binary Conversion
• Convert Decimal To Binary
• Fractional Binary To Decimal
• Converting Hex/decimal To Binary
• Converting Hex To Binary And Decimal
• Converting Binary To Decimal
• Binary To Decimal Conversion
• Converting Binary To Decimal
• Translate Decimal To Binary?
• Convert Binary To Decimal In VB
• Decimal To Binary Function In VB6?
• Decimal Or Binary To Two's Complement
• How To Convert Decimal To Binary
• Converting Binary To Decimal
• How Do I Convert Binary To Decimal ?
• Help Converting Binary To Decimal Numbers..
• Getting HEX & DECIMAL Values (Open As Binary)
• Urgent Decimal To Binary Question...

onverting Numbers To Hex, Octal, Binary, And Decimal


ow can this be done. Also if you can check out my other thread on converting Radians to Degrees I would greatly appreciated it.

nary,Decimal,Hexadecimal, Octal Notation...


ell, I am in computer science now this year. We are learning how to read Binary. I know how to convert binary numbers to decim
umbers somewhat, a little trouble, but still, I wish to know it well.

was wondering if anyone can help me understand the conversions between all Binary, Decimal, Hexadecimal, Octal Notation
umbers/letters.

st explain them all to me, and how to convert each of them. I got a sheet, but it doesn't explain how to convert them.

hanks for your time.


his will be a really big help to me.

ecimal To Binary Converter


y code works, but I cant display the number in a good format...:

ode:
ivate Sub cmdD2B_Click()
cture1.Cls
umber = Val(txtDecimal.Text)
o While Number >= 2
um = Number Mod 2
umber = Int(Number / 2)
cture1.Print Num
oop
Number = 1 Then
cture1.Print 1
seIf Number = 0 Then
cture1.Print 0
nd If
nd Sub

get a Picture box that displays the binary Number vertically...I want to print it horizontally...got any idea's. I would really like to
int it in the text box but that is not necessary!

hanks in advance!
nary To Decimal Converter?
i there I am a beginner to Visual Basic. I am currently running Visual Basic 6.0. So far the only programs I have created are a loa
alyzer and a cash register program. I want to create a program that can convert IP addresses into Binary code and vice versa. suc
255.255.255.255 = 11111111.11111111.11111111.11111111
an anyone please help. This is driving me crazy!!

ecimal & Octal Numbering Systems...


the decimal numbering system the largest number that can be recieved by multiplying two single digits is 81. (9x9=81). 81 can
presented using two digits.

ith how many digits can i represent the largest number that can be recieved with multiplying two single digits in the octal system
ase 8). And which number will that be.

hope i am understood clearly.

onvetring Decimal, Hexadecimal, Octal, ASCII ...


am trying to make a Decimal, Hexadecimal, Octal and ASCII conveter.

know what these do :

lue- My decimal input


x(value)- The HEX value of it
t(value)- The OCTAL value of it
r(value)- The 0-128 ASCII value (letters, characters, etc)
c(value)- If my input is a letter, gives its ASCII value

ow i wanna know how the f*** do i convert 0x11 in hex to decimal (would be 17) ???

nyone that can help, PLEASE DO !

nary To Octal---help!!
m having trouble with regards my very simple program which is converting binary to octal in visual basic. our teacher required u
put only 4 characters. i'm very confused when it comes to LEN. Please help me. Here's what i've started and the output is always
7.

igvalue=val(txtvalue.text)

Right$(Len(origvalue), 1) Then
=1
ext4.Text = a
se
=0
nd If
Right$(Len(origvalue), 2) Then
=4
ext4.Text = a + b
se
=0
nd If

Right$(Len(origvalue), 3) Then
=4
ext4.Text = a + b + c
se
=0
nd If

Right$(Len(origvalue), 4) Then
=8
ext4.Text = a + b + c + d
se
=0
nd If

nary Hex And Octal Conversions


o any of you have any code for converting between these? i have tried to write my own but it horribly failed...

nary To Octal Convertion


ai Gurus,

an anyone help me to convert the


nary to Octal
ctal to Decimal
ecimal to Binary
nary to Decimal
ecimal to Octal
need it urgent..
ease help me.
hanks in advance
atish kumar

Binary To Octal Convertion


earched the archives at
tp://search.ittoolbox.com/Groups/Default.asp?requ est=octal&list=visualbasi
l&area=db

d found:

ebug.Print Hex(123) 'returns Hexadecimal equivalent


ebug.Print Oct(8) 'returns the octal representaiton of decimal
you search the msdn you'll hopefully have more luck.

---Messaggio originale-----

ow Do I Convert An Octal (base 8) Value To A Decimal Value (base 10)


ow do i convert an octal (base 8) value to a decimal value (base 10)

nary Converter
have created a program that converts from text to binary, but I dont know how to decode it... can anyone help? If you need my
de.. here it is so far.

B Code:
im loopcounter As Integer Public Function cBIN(ByVal ic As Integer) As StringDim x As Long, bC As BytecBIN = ""x = 256Fo
1 to 8       bC = 0       x = x / 2       If iC >= x Then       bC = 1       iC = iC - x       End If    cBIN = cBIN & bCNext YEnd
unction Private Sub cmdConvert_Click()Text2.Text = "" For loopcounter = 1 to Len(Text1.Text)     singlechar = Mid(Text1.Text,
opcounter, 1)     int char = Asc(singlechar)     Text2.Text = Text2.Text & cBin(intchar) & " " NextEnd Sub

hanks in advance

nary/integer Converter
ed a bit of a big help here. i got my NIM game halfway there under my own steam. BUT........ Now i am at the stage that i need a
ort program to convert integer to binary, then perform an XOR, and finally do a binary to integer conversion.

ny help? Push in the right direction, or if you have got one already?

nary To String Converter


i guys/gal's

m making a string to binary converter for us lazy ass students and its going cool...BUT....it'd be nice if it converted it back the oth
ay as well (Binary to Decimal and Binary to String)

ny help would be great.

heers
d

onversion Binary To Binary And Conversion Of Hexadecimal To Decimal In Calculator


i Folks

was develop one scientific calculator

binary to binary conversion= for example we can add one binary value (1110) + another binary value(0101) = i want this
utput(100 1 1)but it comes 1211 this is my question how can i rectify ?
convert from hexadecimal to decimal conversions (ex)in decimal 12 to hexa is c . it wirks good ,but my question is how to conv
xadecimal to deimal (12) ?
ks in Advance
--------------------------------------------------------------------
ARD WORK NEVER END FAILS"

ecimal To Binary
m trying to find a way to convert decimal to binary in vb, i searched around and found:

B Code:
im Number As IntegerDim Binary_String As String Number = Val(Text1.Text)Binary_String = ""While Number > 0   
nary_String = Str(Number Mod 2) & Binary_String    Number = Number 2WendText2.Text = Binary_String

is works fine except for it leaves spaces in between each character when i run it, what is wrong with this code?

ecimal To Binary
m programming a subnet mask calculator and i need to change a decimal value entered by the user to binary value which will be
splayed in a label...any ideas?

isco Duck

ecimal To Binary
st ewondering if there is a simple way of converting a decimal number to its binary equivalent

nary To Decimal
need to change a string which is a 12 bit binary value into its decimal equivilant.

ny easy way?

heers in advance

ndy Dunn

ecimal To BInary
elp

need to change a deciml number, say 28 into its equivialnt binary pattern 011100?

ny easy way?

heers in Advance

ndy
nary To Decimal
need to convert a binary number, read from a text file, to it's decimal equivalent. It's in two's complement format, i.e can be
gative.
oes anybody have a suitable routine or can anyone point me in the right direction?

any thanks

nary To Decimal Help!


ght now I have a VB project I need to complete for school. And to be honest I need a little help.

he project is to create a program to convert an 8 digit binary number into a decimal number. Remember I'm a newbie so please do
ost functions.

I probably won't be able to understand them, and 2. I need to submit the source code with the program.

understand prefectly how decimal numbers are calculated from binary. And all I really need to find out is the code for analysing
ch individual digit so I can tell VB to than if the first place is 1 make a variable with the vale 2^0 and if the second place is 1 ma
other with the value 2^1 etc... That really is the key to my sucess at the moment.

EEEEEEEEEEEELLLLLLLLLLLLLLPPPPPPPPPPPPPPPP!

ex/decimal To Binary

need to know if there is any way to convert hex or decimal to its equicvalent binay format
need only 4 bit binary....
hanx in advance
rs

nd miles to go before i sleep..........

nary/Hex/Decimal Arithmetic
need to do the following:

ode:
2 80 00 3 hex values
0000010 10000000 00000000 binary form of each
000010 0000000 0000000 drop bit 7
00001000000000000000 concatenate
000|0000|1000|0000|0000|0000 create 4-bit groups starting from right
0 8 0 0 0 hex value of each group
2768 decimal value of above
nything I have attempted so far does not produce the correct result.

am having trouble with the convert to binary part.


elp would be appreciated.

nary/Hex/Decimal Conversions
there a function, API call, or something that can convert a binary/hex/decimal to binary/hex/decimal? I know Hex() does hex, bu
there a way to do binary decimal and so on? Thanks.

ecimal 2 Binary Conversion


ello everyone...

ould anyone tell me how to convert an integer less than 25 into a 4 bit binary number

nary To Decimal And The Reverse


am lost as to why this program doesn't work... with number over 255 any ideas I can't find a problem with the logic at all! Thank
re is the coding and it is in the sip file as well:

ode:
im i, Power, Number, DecNum As Integer
im Digit As Single

ivate Sub cmdB2D_Click()


tDecimal.Text = ""
ower = Len(txtBinary.Text)
umber = Val(txtBinary.Text)
or i = 0 To Len(txtBinary.Text) - 1
ecNum = DecNum + Right(Number, 1) * 2 ^ i
umber = Left(Number, Len(Number) - 1)
ext i
tDecimal.Text = DecNum
ecNum = 0
nd Sub

ivate Sub cmdD2B_Click()


cture1.Cls
umber = Val(txtDecimal.Text)

o While Number >= 2


um = Num & Number Mod 2
umber = Int(Number / 2)
Number = 1 Then
um = Num & 1
seIf Number = 0 Then
um = Num & 0
nd If
oop
or i = 0 To Len(Num) - 1
nary = Right(Num, 1) & Binary
um = Left(Num, Len(Num) - 1)
ext i
Len(Binary) <= 8 Then
tBinary.Text = Format(Binary, "00000000")
seIf Len(Binary) > 8 Then
tBinary.Text = Format(Binary, "00000000 00000000")
nd If
nd Sub
hanks!

nary/Decimal Conversion
k: i was looking at this thread: http://www.xtremevbtalk.com/show...ary+conversion
d i thought it would be really cool to make a program that converts binary to decimal, and vice versa..

his code works great

ode:
im Binstr As String
exstr = Hex$(number)
or LV = 1 To Len(HexStr)
elect Case Mid$(Hexstr, LV, 1)
ase "0"
nStr = BinStr & "0000"
ase "1"
nStr = BinStr & "0001"
ase "2"
nd so on.
ase "15"
nStr = BinStr & "1111"
nd Select
ext

he thing is, i dont understand why.. can someone please explain it to me?

BA Decimal To Binary Query!


ick_robo
ewcomer

ined: Apr 2003


is is my function to convert a decimal no. to a binary no.
there a way that i can use a do, loop command rather than the while, wend command.

unction tobinary(x As Integer) As String


im s As String
x = 0 Then
= "0"
se
= ""
hile x <> 0
= (x Mod 2) & s
= Int(x / 2)
end
nd If
binary = s
nd Function

anks!

onvert Decimal To Binary??


umb question... is there a built in function to convert decimal numbers to binary?

convert 164 to 10100100

r am I going to have to write a function to do this?

l, something I never thought I'd need to do.

eudocode For Binary To Decimal In VB Plz


can someone help me with the pseudocode for Binary to Decimal plz?

ecimal To Binary Conversion


need someone to confirm that this code I've written will turn an integer value under 255 into a 8 bit binary without error (counter
e integer to be changed, and tempdata is a public string holding the return binary code). Thanks in advance...

ode:
unction BinaryConvert(convert As Integer)

convert > 255 Then


sgBox "Too big to convert", vbOKOnly, "Not Convertable"
xit Function
nd If

convert <= 255 And convert > 127 Then


mpdata = tempdata & "1"
nvert = convert - 128
se
mpdata = tempdata & "0"
nd If

convert <= 127 And convert > 63 Then


mpdata = tempdata & "1"
nvert = convert - 64
se
mpdata = tempdata & "0"
nd If

convert <= 63 And convert > 31 Then


mpdata = tempdata & "1"
nvert = convert - 32
se
mpdata = tempdata & "0"
nd If

convert <= 31 And convert > 15 Then


mpdata = tempdata & "1"
nvert = convert - 16
se
mpdata = tempdata & "0"
nd If

convert <= 15 And convert > 7 Then


mpdata = tempdata & "1"
nvert = convert - 8
se
mpdata = tempdata & "0"
nd If

convert <= 7 And convert > 3 Then


mpdata = tempdata & "1"
nvert = convert - 4
se
mpdata = tempdata & "0"
nd If

convert <= 3 And convert > 1 Then


mpdata = tempdata & "1"
nvert = convert - 2
se
mpdata = tempdata & "0"
nd If

convert <= 1 And convert > 0 Then


mpdata = tempdata & "1"
nvert = convert - 1
se
mpdata = tempdata & "0"
nd If

nd Function

onvert Decimal To Binary


ello all,

have just written a function to convert a decimal number into binary. The function works fine with just one problem, I need the
umber in eight bit binary format.

or example my code will convert the number ten into 1010. I need it to convert it so it reads 00001010. This is my current code;

ode:
ublic Function inttobin(ByVal decnum As Long) As String
im binstring As Integer
o While decnum <> 0
nstring = decnum Mod 2
ttobin = binstring & inttobin
cnum = Int(decnum / 2)
oop
nd Function
he only way I could think of achieving this was like this;

ode:
ublic Function inttobin(ByVal decnum As Long) As String
im binstring As Integer

o While decnum <> 0


nstring = decnum Mod 2
ttobin = binstring & inttobin
cnum = Int(decnum / 2)
oop

o While Len(inttobin) <> 8


ttobin = "0" & inttobin
oop

nd Function
ut this seems a like a bad way to do it. Is there anyway I can make sure that the inttobin string is always 8 bits with any additiona
uffered bits being 0?

actional Binary To Decimal


an someone please post the VB6 code for this? It's urgent. Please.. and I would want a very simple, very basic code... please help

onverting Hex/decimal To Binary


know how to convert hex to decimal and visa versa but how to convert hex and decimal to BINARY :S

onverting Hex To Binary And Decimal


i,
oes anyone have any example code to convert;
ex To Decimal
nary to Decimal
ex to Binary

hanks

onverting Binary To Decimal


need to convert an string of 3 characters which contains a number in binary code to a double variable. The coded number (which
ad form a .dbf file) has two decimals, so I suppose it is stored in floating point format. Is there any function to do this in VB?

hanks.

nary To Decimal Conversion


Iam a nerd vb programmer lured by the beauty of it.I want to explore more in it.I want to view data from excel application in a te
ox.I don't want to use data control.I want it to be done through an object of excel dll.
hank any one who helps me to find a solution for it.I require the coding also as I am new to excel communication.

How to do digital to analog or binary to decimal conversion in vb.I require the coding also as I am new to this type of
ogramming.

appreciate and thank the person who helps me to solve the above problems.

y one with a solution can contact me at:s_subbarayan@yahoo.com

onverting Binary To Decimal


am almost finished a project in work but I need code to convert from binary to decimal. Can anyone help?

anslate Decimal To Binary?


i,

have asked this question before but I can't remember the answer (sorry). I have a text box called txtDecimal and would like to
anslate the number in there into Binary and then display it in a label called lblBinary. Could somebody please help?
hanks

onvert Binary To Decimal In VB


ve been looking for a way to do this for about two weeks now. Searching Google, Yahoo and even these forums. My question is.
ow can you convert Binary to Decimal? The app I am writing needs to take a binary number that someone enters into a text box,
nvert it to decimal and output that to another text box. This would be done with a button click event of course. I've got everythin
gether except that part. I'm using Visual Studio 2005. Any help would be appreciated.

ecimal To Binary Function In VB6?


i, is there a function in VB6 which will convert a number to a binary format, or has anyone got a function i can use?

hanks in advance,
hris

ecimal Or Binary To Two's Complement


an anyone give me a piece of code that might convert a decimal number to two's complement? Or else, a code that might convert
nary number to two's complement.
ake a look at this page:
tp://www.codeguru.com/forum/showt...205#post1226205

ow To Convert Decimal To Binary


want to convert decimal to binary Help me please

onverting Binary To Decimal


there a function that converts a binary number into a decimal and the other way around?

: 10011101 should return 157


: 156 should return 10011100

gards

om Cannaerts
sse@planetinternet.be

he best way to escape a problem, is to solve it.

ow Do I Convert Binary To Decimal ?


want to convert Binary to decimal with VB , can soemone pleasssssssssse help me , thanx a lot !

elp Converting Binary To Decimal Numbers..


was just wondering how do you convert numbers between base 10 and base 2?
etting HEX &amp; DECIMAL Values (Open As Binary)
d like to get the actual HEX and DEC values of a known byte position when opening a file for BINARY ACCESS. Here is the
enario -- or maybe I'm on the wrong track with the Opening for Binary:

XAMPLE:

know the position of the bytes that I want to read are 41, 42, 43, 44

open and get to that as follows (it may not be the easiest way to get it but it makes it clearer to me how I get to it):

heFile = "C: estmyfile.etc"


pen TheFile For Binary Access Read As #1
im temp As String
mp = Space$(44)
et #1, , temp
ose #1
yData = Right(temp, 4)

Now that I have the data (MyData) I want to display it as follows:

yDataInHex = ???????? (Help Here)


yDataInDec = ???????? (Help here)

ext1.text = MyDataInHex 'Eg: 00 08 00 00


ext2.text = MyDataInDec 'Eg: 2048 (Hex read in little endian)

or an extra "topping", sometimes my HEX value will represent ASCII. An example is:

ext3.text = MyDataInHex 'Eg: 64 61 74 61


ext4.text = MyDataInAsci 'Eg: data

ow ---- thanks for letting me ask this one and thanks in advance.

rgent Decimal To Binary Question...


m going to be making a decimal to binary converter.

e problem I'm having is writing the binary from right to left so that it'll be displayed correctly.

:
have it as,
01001101

stead of,
01100100

Privacy Policy | Terms of Use & Service | Contact Us | Copyrights Notice


Copyright © 2005-08 www.BigResource.com, All rights reserved

You might also like