假如有两个数组arr1(0 to 100),arr2(0 to 50),想将Arr1中内容加到arr1后面: '增大空间: redim preserve arr1(0 to 151) as byte '拷贝 '法一 arr1(101)=arr2(0) arr1(102)=arr2(1) ... ... ... ' 法二: copymemory arr1(101),arr2(0),51
用REDIM未遂 ??????? 为什么会未遂呢?是不是自己没有定义成动态的数组?
用copymemory Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Private Sub Command1_Click() Dim a(10) As Byte Dim b(10) As Byte Dim c(20) As Byte For i = 0 To 10 a(i) = i + 2 c(i) = i Next CopyMemory c(11), a(0), 11*1'byte占一个字节,integer占2个字节... For j = 0 To 20 Debug.Print c(j) Next End Sub
'增大空间:
redim preserve arr1(0 to 151) as byte
'拷贝
'法一
arr1(101)=arr2(0)
arr1(102)=arr2(1)
... ... ...
' 法二:
copymemory arr1(101),arr2(0),51
???????
为什么会未遂呢?是不是自己没有定义成动态的数组?
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Sub Command1_Click()
Dim a(10) As Byte
Dim b(10) As Byte
Dim c(20) As Byte
For i = 0 To 10
a(i) = i + 2
c(i) = i
Next
CopyMemory c(11), a(0), 11*1'byte占一个字节,integer占2个字节...
For j = 0 To 20
Debug.Print c(j)
Next
End Sub