RSS Forums RSS
Please support our VB.NET advertiser: Programming Forums

Conversion

Join Date: May 2006
Posts: 1
Reputation: vinay_lnt is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
vinay_lnt vinay_lnt is offline Offline
Newbie Poster

Help Re: Conversion

  #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  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 6:56 pm.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC