Solved

HEX to Binary

Posted on 2004-08-13
2
3,820 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

820 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