Function Hex2Dec(inHex As String) As Long
' Copywrite (c) 2004 Randy Gamage
' This function takes a Hexadecimal string
' and outputs a decimal (long) result
Dim i As Integer
Dim j As Long
Dim ch As String
Dim k As Integer
For i = 1 To Len(inHex)
 ch = Mid(inHex, Len(inHex) - i + 1, 1)
 k = Asc(ch)
  Select Case k
    Case 48 To 57
      j = j + k - 48
    Case 65 To 70
      j = j + k - 55
    Case 97 To 102
      j = j + k - 87
    Case Else
      MsgBox ("Invalid data for Hex2Dec function")
  End Select
 j = j * 16 ^ (i - 1)
 Hex2Dec = Hex2Dec + j
 j = 0
Next i
End Function