[vb quest] convert a decimal to binary

Status
Not open for further replies.

mach

Broken In
hi there,
can ny1 tell me how to convert a decimal no into binary in visual basic 6.0

sending the function a call (argument is the decimal)
getting back the binary as string

say i send a no 45
i need to return the string :101101

can ny1 help me d this
thnx
 

legolas

Padawan
usually, the method of converting decimal to binary is to convert to hexa and then write it in 4's i think. (45)10 = (2D)16. then u can write 2D as, (0010)(1101).

if u need the alg. this is it. in any programming language, the alg. is wat imp. u can code using the syntax and commands.

/legolas
 

alib_i

Cyborg Agent
The most basic algo will be to divide the number by 2 in a loop .. till it's <2
and take the reminder at each step

A simple google search gives the algo in visual basic code.
*www.vb-helper.com/howto_decimal_to_binary.html
*www.freevbcode.com/ShowCode.asp?ID=1126

----
alibi
 

thetopcyborg

Journeyman
you can even use the windows inbuilt calculator.....

from view, select scientific.....press F6(to ensure that u r entering the numerals in decimals)....then press F8...the number which is displayed is the binary form of the nunmber which you entered earlier.....u can use this in vb6 then :lol:

eg, i pressed F6....entered 4784and then i pressed F8....the number which was displayed was 1001010110000 which is the binary form of 4784


p.s if you don't wanna press F8 and F6, there are radio buttons on the left(top) corner of the scientific calc....use that
 
Status
Not open for further replies.
Top Bottom