Same as
yesterday[
^], but with a different increment:
Shared Function HexStringToBytes(ByVal hexString As String) As Byte()
Dim result As New List(Of Byte)()
For i As Integer = 0 To hexString.Length - 1 Step 3
result.Add(Convert.ToByte(hexString.Substring(i, 2), 16))
Next
Return result.ToArray()
End Function
Or, using a variation of your function:
Shared Function HexStringToBytes(ByVal input As String) As Byte()
Dim byteStrings() As String = input.Split(New Char() {"-"c})
Dim retVal() As Byte = Array.ConvertAll(byteStrings, Function(s) Convert.ToByte(s, 16))
Return retVal
End Function
EDIT: Based on your comment, you are actually trying to convert an array of bytes to a string. Again, I gave you that function yesterday:
Shared Function BytesToHexString(ByVal bytes As Byte()) As String
Dim sb As New StringBuilder()
For i As Integer = 0 To bytes.Length - 1
sb.Append(bytes(i).ToString("X2"))
Next
Return sb.ToString()
End Function