Solved

Opposite of Hex function?

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

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

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 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

14 Experts available now in Live!

Get 1:1 Help Now