Jagadeesh
Jagadeesh

Reputation: 1800

Convert 2-Dimension array to 1-Dimension array in classic asp

I want to convert the two dimension array to one dimension array in asp. Is this possible? If then please give me one example on this.

Upvotes: 0

Views: 332

Answers (1)

Control Freak
Control Freak

Reputation: 13243

Here is a function that will do it for you:

Function TransformToSingleArray(TwoDimArray)

 TotalValues = (uBound(TwoDimArray,1) +1) * (uBound(TwoDimArray,2) +1)
 ReDim OneDimArray(TotalValues)
 ArrCnt = 0

 For x = lBound(TwoDimArray,1) to uBound(TwoDimArray,1)
   For y = lBound(TwoDimArray,2) to uBound(TwoDimArray,2)
      EachValue = TwoDimArray(x,y)
      OneDimArray(ArrCnt) = EachValue
      ArrCnt = ArrCnt + 1
   Next     
 Next

 TransformToSingleArray = OneDimArray

End Function

Upvotes: 1

Related Questions