How to Combine Two Arrays in ASP

Arrays provide you with a method to contain several values within one ASP variable. Arrays are critical variables that can store multiple values for use on your Web page calculations. You can combine and merge two arrays into a single array using basic loop procedures. Each array element is combined into a new, third array that holds the values of both arrays when you run the code.

Instructions

    • 1

      Click the Windows "Start" button and select "All Programs." Click "Microsoft .NET," then click "Visual Studio." Open the .NET project after Visual Studio loads.

    • 2

      Create a third array. The third array lets you add each of the other arrays' elements and store the results. The following code shows you how to create an array:

      string[] myarr = null;

    • 3

      Merge the two arrays and store the values in the third "myarr" array. The following code shows you how to combine the two arrays:

      size= uBound(array1) + uBound(array2) + 1

      redim preserve myarr(size)

      for (int i = 0; i < to uBound(array2); i++)

      myarr(uBound(array1) + 1 + i) = array2(i)

      loop

      The code above evaluates the total size of the first two arrays. The loop structure iterates through each array's values and assigns the results to "myarr."

Related Searches:

References

Comments

Related Ads

Featured