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!

Sample script to combine 2D arrays

Summary: If you have 2 2D arrays and you need to combine them together, this script will do that.
 
Keywords: ARRAY
COMBINE
DIMENSION
MULTI
Applicable Software: Active Server Pages (ASP)
 
Body:

This code shows the building of 2 sample 2 dimension arrays in the format that .GetRows() returns.

Dim aDB1, aDB2, aFinal
Dim iBound1, iBound2
Dim iCnt_Cols, iCnt_Rows

	ReDim aDB1(1, 9)	'0=ID, 1=Name"
    aDB1(0, 0) = 1: aDB1(1, 0) = "Bob"
    aDB1(0, 1) = 2: aDB1(1, 1) = "Joe"
    aDB1(0, 2) = 3: aDB1(1, 2) = "Ben"
    aDB1(0, 3) = 4: aDB1(1, 3) = "Kit"
    aDB1(0, 4) = 5: aDB1(1, 4) = "Jon"
    aDB1(0, 5) = 6: aDB1(1, 5) = "Rob"
    aDB1(0, 6) = 7: aDB1(1, 6) = "Kim"
    aDB1(0, 7) = 8: aDB1(1, 7) = "Sam"
    aDB1(0, 8) = 9: aDB1(1, 8) = "Max"
    aDB1(0, 9) = 10: aDB1(1, 9) = "Red"

	ReDim aDB2(2, 4)	'0=ID, 1=Name
    aDB2(0, 0) = 11: aDB2(1, 0) = "Sally"
    aDB2(0, 1) = 12: aDB2(1, 1) = "Chris"
    aDB2(0, 2) = 13: aDB2(1, 2) = "Jefry"
    aDB2(0, 3) = 14: aDB2(1, 3) = "Scott"
    aDB2(0, 4) = 15: aDB2(1, 4) = "Shawn"

	'get the lowerbound of the 2 arrays
	iBound1 = UBound(aDB1, 1)
	If UBound(aDB1, 1) < UBound(aDB2, 1) Then iBound1 = UBound(aDB2, 1)
	
	'create a 3rd array that is the size of the lowest of the 2
	ReDim aFinal(iBound1, UBound(aDB1, 2) + UBound(aDB2, 2) + 1)

	'put aDB1 into the final array
	For iCnt_Cols = 0 To UBound(aDB1, 1)
		For iCnt_Rows = 0 To UBound(aDB1, 2)
			aFinal(iCnt_Cols, iCnt_Rows) = aDB1(iCnt_Cols, iCnt_Rows)
		Next
	Next
	
	'get the starting point for the next array
	iBound2 = UBound(aDB1, 2) + 1
	
	'put aDB2 into the final array
	For iCnt_Cols = 0 To UBound(aDB1, 1)
		For iCnt_Rows = 0 To UBound(aDB2, 2)
			aFinal(iCnt_Cols, (iCnt_Rows + iBound2)) = aDB2(iCnt_Cols, iCnt_Rows)
		Next
	Next

 
Author: Douglas L. Setzer, II, http://www.27seconds.com
Posted On: 3/5/2002 12:07:51 PM

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

Article Search   |   All Articles

 

 
©2002 27 Seconds, Inc. All Rights Reserved.