I need help in converting binary to decimal. :sad:

Recommended Answers

All 9 Replies

Welcome to the forums,

I have written a program called "Conversion" a while back. It does exactly what you are looking for and more:

  • Decimal to Hex
  • Hex to Decimal
  • Hex String to Decimal
  • Decimal to Binary
  • Binary to Decimal
  • Float to Binary
  • Ascii to Binary
  • Binary to Ascii

It's an open source project. Well, back to your original question I see that you need it done in VB. My source code was written in C, but if you know how to convert C to VB, or anyone else that is a VB expert, that would be helpful.

Here is a look on how to convert Binary to Decimal:

#include <string.h>

int btoi(char *buf) {
	// Create local variables
	int count, tmp;
	int retValue = 0;

	// Get length of string
	count = strlen(buf);

	// Go through string one byte at a time (backwards)
	for (i = 0; i <= count; i++) {
		// If a number '1' was found
		if (buf[count-i] == '1') {
			tmp = 1;
			for (j = 1; j < i; j++)
				tmp *= 2;
			retValue += tmp;
		}
	}

	// Return our decimal value
	return retValue;
}

*buf is your binary value in string format.

It's pretty much the syntax that will get you started. It's not hard to understand at all. I hope this gets you a head start, and good luck.


- Stack Overflow

I need some help converting flaot to binary, do you still have the converstion program lying around? thanks!!

Welcome to the forums,

I have written a program called "Conversion" a while back. It does exactly what you are looking for and more:

  • Decimal to Hex
  • Hex to Decimal
  • Hex String to Decimal
  • Decimal to Binary
  • Binary to Decimal
  • Float to Binary
  • Ascii to Binary
  • Binary to Ascii
Public Function B2D(BinVal As String) As String
Dim iVal#, temp#, i%, Length%

Length = Len(BinVal)

For i = 0 To Length - 1
    temp = CInt(Mid(BinVal, Length - i, 1))
    iVal = iVal + (temp * (2 ^ i))
Next i

B2D = iVal
End Function

Welcome to the forums,

I have written a program called "Conversion" a while back. It does exactly what you are looking for and more:

  • Decimal to Hex
  • Hex to Decimal
  • Hex String to Decimal
  • Decimal to Binary
  • Binary to Decimal
  • Float to Binary
  • Ascii to Binary
  • Binary to Ascii

It's an open source project. Well, back to your original question I see that you need it done in VB. My source code was written in C, but if you know how to convert C to VB, or anyone else that is a VB expert, that would be helpful.

Here is a look on how to convert Binary to Decimal:

#include <string.h>

int btoi(char *buf) {
	// Create local variables
	int count, tmp;
	int retValue = 0;

	// Get length of string
	count = strlen(buf);

	// Go through string one byte at a time (backwards)
	for (i = 0; i <= count; i++) {
		// If a number '1' was found
		if (buf[count-i] == '1') {
			tmp = 1;
			for (j = 1; j < i; j++)
				tmp *= 2;
			retValue += tmp;
		}
	}

	// Return our decimal value
	return retValue;
}

*buf is your binary value in string format.

It's pretty much the syntax that will get you started. It's not hard to understand at all. I hope this gets you a head start, and good luck.


- Stack Overflow

Hi, I need Hex to Decimal Conversion programmer.
and hex to Date conversion programmer. if any one have it send it this id pthulasiram@rediffmail.com or pthulasiram@yahoo.com. send it pls.

i need one coversion programmer in C for hex to Decimal conversion.
than one more programmer i need for hex to Date conversion in C.
this this hex value - 335455C8. this value convert to Date. the date count start for . 1.1.1970 02:00:00.
can any one u send me my id for pthulasiram@rediffmail.com or pthulasiram@yahoo.com.

i need some help for a code to convert binary 16 to float in C/C++.
:sad: :sad: :sad: please help asap...
i tried to search but couldn't find it... i need it asap..
help!

Welcome to the forums,

I have written a program called "Conversion" a while back. It does exactly what you are looking for and more:

  • Decimal to Hex
  • Hex to Decimal
  • Hex String to Decimal
  • Decimal to Binary
  • Binary to Decimal
  • Float to Binary
  • Ascii to Binary
  • Binary to Ascii

It's an open source project. Well, back to your original question I see that you need it done in VB. My source code was written in C, but if you know how to convert C to VB, or anyone else that is a VB expert, that would be helpful.

Here is a look on how to convert Binary to Decimal:

#include <string.h>
 
int btoi(char *buf) {
    // Create local variables
    int count, tmp;
    int retValue = 0;
 
    // Get length of string
    count = strlen(buf);
 
    // Go through string one byte at a time (backwards)
    for (i = 0; i <= count; i++) {
        // If a number '1' was found
        if (buf[count-i] == '1') {
            tmp = 1;
            for (j = 1; j < i; j++)
                tmp *= 2;
            retValue += tmp;
        }
    }
 
    // Return our decimal value
    return retValue;
}

*buf is your binary value in string format.

It's pretty much the syntax that will get you started. It's not hard to understand at all. I hope this gets you a head start, and good luck.


- Stack Overflow

Hi
i need help for converting binary to ascii :sad: :-(

Hey could one of you guys help me out by showing me how to do this in VB? I'm really not much with computers in general, but I have to pass the VB class (graduation requirement) and at this rate...I don't know that I'll make it. Please help, it would be greatly appreciated.

does anyone has the binary to ascii conversion code? thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.