How to avoid repeating the array definition

Source: Internet
Author: User
Tags array definition definition
Arrays | Repeat when we are using dim, avoid redefining the array. Because you might want to redefine the number with ReDim.
The size of the group. As for this operation, if your machine memory is not very large, it is best to
Think of the worst in the first place. Set the length of the array or the length of the optimal state, in the non
Use ReDim often when necessary. Of course this doesn't mean going to add memory if you're not very much in need of
Words

The following examples illustrate improper use of ReDim
<%
Dim myarray ()
Redim Myarrray (2)
MyArray (0) = "Hello"
MyArray (1) = "Good-bye"
.
.
.
Some other code where and the up needing
More space happens then ...
Redim Preserve myarray (5)
MyArray (2) = "More Stuff"
MyArray (3) = "Even more stuff"
MyArray (4) = "Yet more Stuff"
%>
In fact, at the beginning of the definition of MyArray (5), and later need to use ReDim to increase his size,
This may take up some memory, but it will be much faster.



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.