Solved

HEX to Binary

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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/…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 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

11 Experts available now in Live!

Get 1:1 Help Now