Public Function HexStringToByte(ByVal data As String, ByVal pos As Integer) As Byte
  On Error Resume Next
  Dim c1 As Integer
  Dim c2 As Integer
  Dim temp As Long
  Dim temp2 As Long
  temp = 0
  For c1 = 0 To 1
    temp2 = 0
    c2 = pos - c1
    If c2 >= 0 Then
      temp2 = CLng(Asc(UCase(Mid(data, c2 + 1, 1))))
      If temp2 < 65 Then
        temp2 = temp2 - &H30
      Else
         temp2 = temp2 - &H37
      End If
      If c1 = 1 Then
        temp2 = temp2 * 16
      End If
      temp = temp + temp2
    End If
  Next c1
  HexStringToByte = CByte(temp)
End Function