March 1st, 2012, 08:52 PM
Binary to Decimal or vise versa
I know how to use during decimaltobinary and binarytodecimal function on vb 2010,but i cant figure out the way to output without using vb 2010 function
can anyone send me code on how to create a code for converting binary to decimal and decimal to binary without using vb function please.
March 1st, 2012, 10:13 PM
Why wouldn't you want to use the built-in conversion function in your vb project?
Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
March 2nd, 2012, 09:40 AM
because it says on my paper not to use built in function.
Originally Posted by Doug G
can you please tell me if its possible to convert Binary to decimal and decimal to binary without built in fuction and how?
March 2nd, 2012, 12:58 PM
Of course it's possible but since it's already done for us we wouldn't bother. Obviously this is intended as an exercise for you to work out. I'd probably look at a C function that does this and convert it to VB.
“Today you are You, that is truer than true. There is no one alive who is Youer than You.” - Dr. Seuss
March 28th, 2012, 01:37 AM
One must assume that you are talking whole numbers here. All numbers are stored in the computer as binary numbers, but each type of number (short integer, long integer, single precision, double precision etc) has it's own storage methodology. So assuming we are dealing with a 16 bit integer:
Originally Posted by joyride123
Private Sub cmdConvert_Click()
Dim Number As Long
Dim sBinary As String
Number = Val(Text1.Text)
sBinary = String(16, "0")
Do Until N% > 15
If Number And 2 ^ N% Then
Mid$(sBinary, 16 - N%, 1) = "1"
N% = N% + 1
Text2.Text = sBinary
The form would have 2 text boxes and 1 command button. Since most languages don't deal directly with binary numbers, we have to represent it as a binary string. Conversion back would just be the reverse.