|
-
Dec 2nd, 2004, 12:16 PM
#1
Thread Starter
Junior Member
Copy from array1() to array2()? no loop? [solved]
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
Last edited by runtime; Dec 2nd, 2004 at 05:10 PM.
-
Dec 2nd, 2004, 12:22 PM
#2
Hyperactive Member
"I don't want to live alone until I'm married" - M.M.R.P
-
Dec 2nd, 2004, 12:48 PM
#3
Thread Starter
Junior Member
extract from element 4 to element 390
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
-
Dec 2nd, 2004, 01:09 PM
#4
Hyperactive Member
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
"I don't want to live alone until I'm married" - M.M.R.P
-
Dec 2nd, 2004, 01:15 PM
#5
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
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Dec 2nd, 2004, 05:09 PM
#6
Thread Starter
Junior Member
Thanx crptcblade CopyMemory works great!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|