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 builtin conversion function in your vb project?
======
Doug G
======
I've never been able to appreciate the sublime arrogance of folks who feel they were put on earth just to save other folks from themselves .."  Donald Hamilton
March 2nd, 2012, 09:40 AM

Originally Posted by Doug G
Why wouldn't you want to use the builtin conversion function in your vb project?
because it says on my paper not to use built in function.
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.
medialint.com
“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

Originally Posted by joyride123
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.
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:
Private Sub cmdConvert_Click()
Dim N%
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"
End If
N% = N% + 1
Loop
Text2.Text = sBinary
End Sub
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.