StrConv 将数组转换字符串问题

Dim s(5) As Byte ‘数组长度为6 偶数
Dim d() As Byte
Dim str As String
For i = 0 To 5
s(i) = 155
Next
str = StrConv(s, vbUnicode)
d = StrConv(str, vbFromUnicode)
For i = 0 To UBound(d)
Debug.Print d(i)
Next
结果:
155
155
155
155
155
155
数组的字节数据与原来一样

复制代码
Dim s(6) As Byte ‘数组长度为7 奇数
Dim d() As Byte
Dim str As String
For i = 0 To 6
s(i) = 155
Next
str = StrConv(s, vbUnicode)
d = StrConv(str, vbFromUnicode)
For i = 0 To UBound(d)
Debug.Print d(i)
Next
结果:
155
155
155
155
155
155
0
数组的最后一个字节被转换为 0

赞(0) 打赏
取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

    暂无评论...