Solved

HEX to Binary

Posted on 2004-08-13
2
3,767 Views
Last Modified: 2012-06-27
I'm searching for a function to convert an hex to binary.

For example, I have HEX 40

I want to convert it to: 01000000

does anyone know where I can find code to do this? It has to be regular VB script, I can't load any kind of components or use any .net stuff to do this.
0
Comment
Question by:WebArchitect_Vince
2 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 11797901
You can download a VB project here:  http://www.codearchive.com/dl.php?dlid=474      (Direct link to the zip file)

This project contains a function called "Hex2Bin" that should do what you want.  Its straight forward VB code so you should be able to lift it into you ASP/VBScript page without any modification.

Hope this helps.
0
 
LVL 2

Accepted Solution

by:
funkyfinger earned 500 total points
ID: 11798016
Function Hex2Bin( strHex )

Dim strBin
Dim strDec
Dim i

strDec = Int( Left( strHex, 1) * 16 + Int( Right( strHex ) )

i=8
While( i >= 0 )
  If( (i^2 AND strDec) = i^2 ) Then
      strBin = strBin & "1"
  Else
      strBin = strBin & "0"
  Endif
  i=i-1
WEnd
Hex2Bin = strBin
End Function
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now