WelcomeServicesPortfolioKnowledge BaseContact Us
27 Seconds, Inc.


Knowledge base View Article

need hosting?

Need hosting? We use and love our host - CrystalTech.com!
Need hosting? We use and love our host - CrystalTech.com!

Text Disguise - CAPTCHA-image/Human Interactive Proof web services

National Holiday Dates and Bank Holiday Dates - web site that provides the dates of national and bank holidays for the United States, United Kingdom, Ireland and Scotland

Holiday Web Service - web services for programmers to provide the dates of national and bank holidays in their applications for the United States, United Kingdom, Ireland and Scotland

Our Family Heart - web site to help families communicate no matter where they are

What?! You haven't heard about the greatest remote controlled flyer to come out in years?! Checkout the FlyTech DragonFly now!

Move 2D array to another

Summary: This is some VB code that moves the contents of a 2D array to another one.
 
Keywords: 2D
ARRAY
VB
VISUAL BASIC
Applicable Software: Active Server Pages (ASP)
 
Body:

Recently, I was working on a VB application. It was using an array that was creating using ADO's GetRows() method. I found that I needed to add an additional column to the array, based on some calculations that occured from within VB.

First thing I tried was ReDim Preserve. That didn't work because you can not change the size of any dimension except the last when you want to use Preserve. Shoot.

So, what I did was created a second array that was one index larger in the first dimension. I then wrote this function to move the contents of the first array into the second:

Private Sub privMove2DArrayContents(ByVal sourceArray As Variant, ByRef targetArray As Variant)
Dim iLowerBound As Integer
Dim iUpperBound As Integer
    For iLowerBound = 0 To UBound(sourceArray, 1)
        For iUpperBound = 0 To UBound(sourceArray, 2)
            targetArray(iLowerBound, iUpperBound) = sourceArray(iLowerBound, iUpperBound)
        Next
    Next
End Sub

 
Author: Douglas L. Setzer, II, http://www.27seconds.com
Posted On: 5/22/2002 6:47:54 AM

Rate this article: Average: n/a
n/a12345678910
Comments?

Article Search   |   All Articles

 

 
©2002 27 Seconds, Inc. All Rights Reserved.