1

i have an array that i want to copy in two-dimensional (like jagged) this is my code :

Dim cB(1000000) As Double
Dim buffer(50, 1000000) As Double

For I = 1 To 1000000
    cB(I) = CInt(Int((50 * Rnd()) + 1))
Next

I can use a for to copy cB to buffer. like this code :

For I = 1 To 10

   For j = 1 To 1000000
        buffer(I, j) = cb(j)
   Next

Next

but i want to know is there any faster method to do this? in vb.net or C# i could use List. is there some thing like this in vb6.0?

thanks.

2 Answers 2

1

Maybe don't copy the array at all?

Function AccessMyArray(arr, i, j)
    ' TODO: add range check using LBound() / UBound()
    AccessMyArray = arr(i * 1024 + j)
End Function
Sign up to request clarification or add additional context in comments.

2 Comments

this is not my problem. i want copy array to multi-dimensional as fast as posible.
I get that, but why do you want to change the array structure so trivially without any real need? Your question seems to focus on turning a one-dimensional array into a uniformly nested array (i.e. one row of 10240 items into ten rows of 1024 items, that's basically a no-op).
1

There isn't a generic List object in VB6, but there is a Dictionary object which is roughly equivalent to the generic Dictionary object in .Net. Set a reference to "Microsoft Scripting Runtime" and you'll find it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.