devxlogo

Copy an Array Faster, Redux

Copy an Array Faster, Redux

Simple is usually best. VB4 introduced direct assignment to Byte arrays, and VB5 later expanded that capability to include other array types as well.

This code does the same thing as the previous tip, with the same performance improvement:

 Dim IntArray1() As IntegerDim IntArray2() As IntegerReDim IntArray1(1 To 6000000)ReDim IntArray2(1 To 6000000)IntArray2 = IntArray1

As the old saying goes: “Keep it simple, stupid.” The previous tip is still useful for copying portions of arrays, but use direct assignment if you need to copy the entire array.

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist