Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HEX to Binary

Posted on 2004-08-13
2
Medium Priority
?
4,004 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 2000 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

972 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