944,118 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 32697
  • VB.NET RSS
Sep 2nd, 2004
0

Conversion

Expand Post »
I need help in converting binary to decimal.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
The Girl is offline Offline
1 posts
since Sep 2004
Sep 2nd, 2004
0

Re: Conversion

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
Reputation Points: 26
Solved Threads: 4
Junior Poster
Stack Overflow is offline Offline
185 posts
since Sep 2004
Jan 22nd, 2005
0

Re: Conversion

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

Quote originally posted by Stack Overflow ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
akila is offline Offline
7 posts
since Jan 2005
Jan 23rd, 2005
0

Re: Conversion

VB.NET Syntax (Toggle Plain Text)
  1. Public Function B2D(BinVal As String) As String
  2. Dim iVal#, temp#, i%, Length%
  3.  
  4. Length = Len(BinVal)
  5.  
  6. For i = 0 To Length - 1
  7. temp = CInt(Mid(BinVal, Length - i, 1))
  8. iVal = iVal + (temp * (2 ^ i))
  9. Next i
  10.  
  11. B2D = iVal
  12. End Function
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Feb 8th, 2005
0

Re: Conversion

Quote originally posted by Stack Overflow ...
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pthulasiram is offline Offline
2 posts
since Feb 2005
Feb 8th, 2005
0

Re: Conversion

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pthulasiram is offline Offline
2 posts
since Feb 2005
Mar 27th, 2006
0

Re: Conversion

i need some help for a code to convert binary 16 to float in C/C++.
please help asap...
i tried to search but couldn't find it... i need it asap..
help!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ariana is offline Offline
1 posts
since Mar 2006
May 2nd, 2006
0

Re: Conversion

Quote originally posted by Stack Overflow ...
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 :-(
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vinay_lnt is offline Offline
1 posts
since May 2006
Feb 1st, 2007
0

Re: Conversion

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
CaitieDavis is offline Offline
1 posts
since Feb 2007
Mar 8th, 2007
0

Re: Conversion

does anyone has the binary to ascii conversion code? thank you.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
alice_C is offline Offline
1 posts
since Mar 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: A simple question
Next Thread in VB.NET Forum Timeline: Error Querying LDAP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC