Imports System
Imports Microsoft.VisualBasic
Module HexTest
Dim hexDigits As Char() = {"0"c, "1"c, "2"c, "3"c, "4"c, _
"5"c, "6"c, "7"c, "8"c, "9"c, _
"A"c, "B"c, "C"c, "D"c, "E"c, "F"c}
Function ToHexString(ByVal bytes() As Byte) As String
Dim chars(bytes.Length * 2) As Char
Dim i As Integer
For i = 0 To bytes.Length - 1
Dim b As Integer = bytes(i)
chars((i * 2)) = hexDigits(b >> 4)
chars((i * 2) + 1) = hexDigits(b And &HF)
Next i
Return New String(chars)
End Function
Sub Main()
Dim b As Byte() = {&H0, &H12, &H34, &H56, &HAA, &H55, &HFF}
Console.WriteLine(ToHexString(b))
End Sub
End Module
'
'This code example produces the following results:
'
'00123456AA55FF
'