Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 31-01-2006, 11:45 PM   #1 (permalink)
Right Off the Assembly Line
 
Join Date: Sep 2005
Location: Amidst the stars
Posts: 15
Default [vb quest] convert a decimal to binary


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
mach is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 01-02-2006, 08:45 AM   #2 (permalink)
Alpha Geek
 
Join Date: Feb 2005
Posts: 959
Default

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
__________________
A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila.
legolas is offline  
Old 01-02-2006, 04:25 PM   #3 (permalink)
Wise Old Owl
 
alib_i's Avatar
 
Join Date: Jun 2004
Location: omnipresent
Posts: 1,191
Default

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.
http://www.vb-helper.com/howto_decimal_to_binary.html
http://www.freevbcode.com/ShowCode.asp?ID=1126

----
alibi
__________________
What I've felt, What I've known; Never shined through in what I've shown
Never free, Never me; So I dub thee unforgiven
-Metallica
alib_i is offline  
Old 01-02-2006, 04:36 PM   #4 (permalink)
In The Zone
 
thetopcyborg's Avatar
 
Join Date: Sep 2005
Posts: 231
Default

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

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
thetopcyborg is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by topgear
- by abhidev
- by clmlbx
- by Sarath

Advertisement




All times are GMT +5.5. The time now is 04:38 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2