使用Hex $()可以轻松地将字节(或更大的值)转换为十六进制表示形式。 但是,它以一或两个字节的形式出现,这可能会使您的文本对齐混乱。 这个简单的函数提供了一个一致的两位数的十六进制字符串。
Public Function HexByte2Char(ByVal Value As Byte) As String
' Return a byte value as a two-digit hex string.
HexByte2Char = IIf(Value < &H10, "0", "") & Hex$(Value)
End Function
From: https://bytes.com/topic/visual-basic/insights/675465-display-byte-two-hex-digits