Hello,
I have an array with 394 byte elements (array1(393)), what would be the fastest method to copy from element 4 to element 390 to another array? Can this be done without loop?
Thank you in advance
Printable View
Hello,
I have an array with 394 byte elements (array1(393)), what would be the fastest method to copy from element 4 to element 390 to another array? Can this be done without loop?
Thank you in advance
array2(390) = array1(4)
array2(390) = array1(4) will copy one element, what I need is array2 to contain from element 4 to element 390 of array1...
Thank you
ohh, ok, sorry for the misinterpretation.
A loop would be the fastest way to do this.
You could do this without a loop but that would take 386 lines of code.
VB Code:
Dim i For i = 4 to 390 array2(i-4) = array1(i) Next i
Something like this...
VB Code:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, _ Source As Any, _ ByVal Length As Long) Private Sub Command1_Click() Dim arr1(0 To 394) As Long Dim arr2(0 To 389) As Long Dim x As Long For x = LBound(arr1) To UBound(arr1) arr1(x) = x Next [b] Call CopyMemory(ByVal VarPtr(arr2(0)), ByVal VarPtr(arr1(0)) + (4 * LenB(arr1(0))), (389 - 4) * LenB(arr1(0)))[/b] For x = LBound(arr2) To UBound(arr2) Debug.Print arr2(x) Next End Sub
Thanx crptcblade CopyMemory works great!
:thumb: