Hex to Byte

  • Thread starter Thread starter Gerald
  • Start date Start date
I figured it out...in case someone else has a need for this, below is a
sample function:

Private Function HexToByte(ByVal HexInput As String) As Byte()
Try
If HexInput.Length > 0 Then
Dim ndx As Integer = 1
Dim i As Integer
Dim ByteCnt As Integer

ByteCnt = HexInput.Length / 2
Dim ByteVar(ByteCnt) As Byte
For i = 0 To ByteCnt - 1
ByteVar(i) = Convert.ToByte(Mid(HexInput, ndx, 2),
16)
ndx = ndx + 2
Next

Return ByteVar

End If

Catch
Err.Raise(Err.Number, "Encryption::HexToByte",
Err.Description)
End Try

End Function
 
Back
Top