User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 402,711 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,391 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 27830 | Replies: 9
Reply
Join Date: Sep 2004
Posts: 1
Reputation: The Girl is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
The Girl The Girl is offline Offline
Newbie Poster

Conversion

  #1  
Sep 2nd, 2004
I need help in converting binary to decimal.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2004
Location: Overflow State
Posts: 183
Reputation: Stack Overflow is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 4
Stack Overflow's Avatar
Stack Overflow Stack Overflow is offline Offline
C Programmer

Re: Conversion

  #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  
Join Date: Jan 2005
Posts: 7
Reputation: akila is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
akila akila is offline Offline
Newbie Poster

Re: Conversion

  #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  
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 107
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Moderator

Re: Conversion

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

Re: Conversion

  #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  
Join Date: Feb 2005
Posts: 2
Reputation: pthulasiram is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
pthulasiram pthulasiram is offline Offline
Newbie Poster

Re: Conversion

  #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  
Join Date: Mar 2006
Posts: 1
Reputation: ariana is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
ariana ariana is offline Offline
Newbie Poster

Re: Conversion

  #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  
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  
Join Date: Jan 2007
Posts: 1
Reputation: CaitieDavis is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
CaitieDavis CaitieDavis is offline Offline
Newbie Poster

Re: Conversion

  #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  
Join Date: Mar 2007
Posts: 1
Reputation: alice_C is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
alice_C alice_C is offline Offline
Newbie Poster

Re: Conversion

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

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb VB.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the VB.NET Forum

All times are GMT -4. The time now is 6:32 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC