Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

HEX to Binary

Posted on 2004-08-13
2
Medium Priority
?
3,960 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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 would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

705 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