ASP Arrays Array

Source: Internet
Author: User

In Asparray follow the same form and rules as these in Vbscriptarray. You can create an array of specific sizes or you can create a vibrant size array. Here we illustrate the two types of array.

<%
Dim Myfixedarray (3) ' Fixed size array
Dim Mydynarray () ' Dynamic size array

%>

We will focus on the fixed size array in the first and overlay dynamic array later in this lesson.

assigning values to arrays

Let's make up for the value of our fixed size array. Our fixed array will store the name of a famous person. To specify an array of values you need to know three things:

The name array
The value to store
Value to store in the location array.
An array is a set of variables that you can specify by the array within the location. Our Arraymyfixedarray has 4 positions: 0, 1, 2 and 3. Let's specify some values for our array.

<%
Dim Myfixedarray (3) ' Fixed size array
Myfixedarray (0) = "Albert Einstein"
Myfixedarray (1) = "Mother Teresa"
Myfixedarray (2) = "Bill Gates"
Myfixedarray (3) = "Martin Luther King Jr."
%>

<%
Dim Myfixedarray (3) ' Fixed size array
Myfixedarray (0) = "Albert Einstein"
Myfixedarray (1) = "Mother Teresa"
Myfixedarray (2) = "Bill Gates"
Myfixedarray (3) = "Martin Luther King Jr."
For each item in Myfixedarray
Response.Write (Item & "<br/>")
Next
%>

ASP array Definition

To create an array, its size can be changed at all times without putting some parentheses inside when you declare the array. When you know you want the size of the array will use the ReDim keyword. You may ReDim many times of your wishes.

If you want your data to already exist in the array and then use the reserved keyword. Here is an example of all these things that we have just talked about.

<%
Dim Mydynarray () ' Dynamic size array
ReDim Mydynarray (1)
Mydynarray (0) = "Albert Einstein"
Mydynarray (1) = "Mother Teresa"
ReDim Preserve Mydynarray (3)
Mydynarray (2) = "Bill Gates"
Mydynarray (3) = "Martin Luther King Jr."
For each item in Mydynarray
Response.Write (Item & "<br/>")
Next
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.