Conversion

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2004
Posts: 1
Reputation: The Girl is an unknown quantity at this point 
Solved Threads: 0
The Girl The Girl is offline Offline
Newbie Poster

Conversion

 
0
  #1
Sep 2nd, 2004
I need help in converting binary to decimal.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 185
Reputation: Stack Overflow is an unknown quantity at this point 
Solved Threads: 4
Stack Overflow's Avatar
Stack Overflow Stack Overflow is offline Offline
C Programmer

Re: Conversion

 
0
  #2
Sep 2nd, 2004
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
Following the rules will ensure you get a prompt answer to your question. If posting code, please include BB [code][/code] tags. Your question may have been asked before, try the search facility.

IRC
Channel: irc.daniweb.com
Room: #c, #shell
Reply With Quote Quick reply to this message  
Join Date: Jan 2005
Posts: 7
Reputation: akila is an unknown quantity at this point 
Solved Threads: 0
akila akila is offline Offline
Newbie Poster

Re: Conversion

 
0
  #3
Jan 22nd, 2005
I need some help converting flaot to binary, do you still have the converstion program lying around? thanks!!

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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Conversion

 
0
  #4
Jan 23rd, 2005
  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
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 2
Reputation: pthulasiram is an unknown quantity at this point 
Solved Threads: 0
pthulasiram pthulasiram is offline Offline
Newbie Poster

Re: Conversion

 
0
  #5
Feb 8th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 2
Reputation: pthulasiram is an unknown quantity at this point 
Solved Threads: 0
pthulasiram pthulasiram is offline Offline
Newbie Poster

Re: Conversion

 
0
  #6
Feb 8th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 1
Reputation: ariana is an unknown quantity at this point 
Solved Threads: 0
ariana ariana is offline Offline
Newbie Poster

Re: Conversion

 
0
  #7
Mar 27th, 2006
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!
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 1
Reputation: vinay_lnt is an unknown quantity at this point 
Solved Threads: 0
vinay_lnt vinay_lnt is offline Offline
Newbie Poster

Re: Conversion

 
0
  #8
May 2nd, 2006
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 :-(
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 1
Reputation: CaitieDavis is an unknown quantity at this point 
Solved Threads: 0
CaitieDavis CaitieDavis is offline Offline
Newbie Poster

Re: Conversion

 
0
  #9
Feb 1st, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 1
Reputation: alice_C is an unknown quantity at this point 
Solved Threads: 0
alice_C alice_C is offline Offline
Newbie Poster

Re: Conversion

 
0
  #10
Mar 8th, 2007
does anyone has the binary to ascii conversion code? thank you.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC