Solved

Opposite of Hex function?

Posted on 1998-02-01
1
471 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 100 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 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