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

x
?
Solved

Opposite of Hex function?

Posted on 1998-02-01
1
Medium Priority
?
504 Views
Last Modified: 2012-08-14
Hello all!
I am wondering if there is any opposite of the Hex function?
Ex. Hex(255) returns FF.
Then should ThatFunction(FF) return 255!
0
Comment
Question by:martinag
1 Comment
 
LVL 8

Accepted Solution

by:
mrmick earned 400 total points
ID: 1454797
Function HexStringToDecimal(Hex As String) As Long

   Dim strIn$, i&, j&, k&, c$
   strIn = Trim$(Hex)
   If Len(strIn) > 8 Then
      'Overflow
      Exit Function
   End If
   For i = Len(strIn) To 1 Step -1
      c = UCase(Mid$(Hex, i, 1))
      Select Case c
         Case "0" To "9"
            k = k + CLng(c) * 16 ^ j
         Case "A" To "F"
            k = k + (Asc(c) - 55) * 16 ^ j
         Case Else
            'Invalid character Error
            Exit Function
      End Select
      j = j + 1
   Next
   HexStringToDecimal = k

End Function

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

783 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