请问能将字符串直接赋值给Byte数组吗?
同上,谢谢! 问题点数:0、回复次数:3Top
1 楼eports(飘零风)回复于 2003-12-03 22:58:19 得分 0
可以用API函数实现:
Option Explicit
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Sub Command1_Click()
Dim tmpstr As String
tmpstr = "TestCopyString"
Dim i As Long
Dim a() As Byte
i = LenB(StrConv(tmpstr, vbFromUnicode))
ReDim a(i - 1)
CopyMemory a(0), ByVal tmpstr, i
For i = 0 To UBound(a)
Debug.Print a(i)
Next
End Sub
Top
2 楼northwolves(狼行天下)回复于 2003-12-03 23:14:56 得分 0
Private Sub Command1_Click()
Dim x As String
Dim y As String
Dim b() As Byte
x = "中国"
b = x
MsgBox UBound(b)
y = b
MsgBox y = x
End SubTop
3 楼zhufei(朗陶居)回复于 2003-12-04 09:23:59 得分 0
to eports(飘零风)
如果我想把字符串转成十六进制表示,是不是跟你上面的方法一样,先把一个字符串赋值给Byte数组,然后把Byte数组里面的每一个元素转换成十六进制.
还望各位指教Top




