Arrays are the most commonly used in encoding, but unfortunately they do not have a variable length array structure. We can see that C # has an arraylist, so we thought about it and encapsulated it with ASP, the main purpose is to use "redim preserve" to redefine the array size. The following is my code: program code <%
'Written by shaoyun site: www.devjs.com
Class arraylist
Private m_array ()
Private m_count
Private sub class_initialize ()
Redim m_array (0)
M_count = 0
End sub
Private sub class_terminate ()
Redim m_array (0)
M_count = 0
End sub
Public property get count ()
Count = m_count
End Property
Public property get item (INDEX)
Item = m_array (INDEX)
End Property
Public Function add (arritem)
Redim preserve m_array (m_count)
M_array (m_count) = arritem
M_count = m_count + 1
End Function
End Class
%>
The procedure is as follows: program code <%
Dim arr: Set arr = new arraylist
Arr. Add "A": arr. Add "B": arr. Add "C"
Response. Write arr. Count & "<br>"
For I = 0 to ARR. Count-1
Response. Write arr. Item (I) & "<br>"
Next
Set arr = nothing
%>
It is very simple. There is only one public function and two read-only attributes, but it is very practical!