字符串转16进制ASCII
Dim vEncoding As Encoding = Encoding.ASCII
Dim S = "211"
Dim vBuffer() As Byte = vEncoding.GetBytes(S)
Dim vBuilder As StringBuilder
vBuilder = New StringBuilder(S.ToString.Length * 2)
For i As Integer = 0 To vBuffer.Length - 1
vBuilder.Append(vBuffer(i).ToString("x2"))
Next
MsgBox(vBuilder.ToString())
得到结果是:323131 Dim S = "211"
Dim vBuffer() As Byte = vEncoding.GetBytes(S)
Dim vBuilder As StringBuilder
vBuilder = New StringBuilder(S.ToString.Length * 2)
For i As Integer = 0 To vBuffer.Length - 1
vBuilder.Append(vBuffer(i).ToString("x2"))
Next
MsgBox(vBuilder.ToString())
从16进制ASCII到字符则只需
dim s as integer=&H46
msgbox(chr(s))
得到的结果是:F
我的淘宝店:http://hamby.taobao.com