是unicode编码的,就是一个字母都是 两个字节的。这样,我一个英文的string 转换成byte() 就会出现0
其实本来想写个 string和byte数组 互转的函数:
'有问题函数,请勿使用 Public Function string2bytes(ByVal str As String) As Byte() Dim mulBits() As Byte mulBits = str myDebug UBound(mulBits) string2bytes = mulBits End Function Public Function bytes2string(ByRef bytes() As Byte) As String Dim str As String str = bytes() bytes2string = str End Function
string len为 8 的字符串,编程 bytes数组 就是 ubound为 15 (从0开始)了。
所以 上面的函数要小改一下。