Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


July 01, 1999

Understanding VBScript: Arrays


RSS
View this exclusive article with VIP access -- click here to join |
See More VBScript Articles Here | Reprints | Or sign up for our VIP Monthly Pass!
SideBar    Using VBScript Arrays in Scripts

Last month, I discussed three basic syntax elements: variables, constants, and subtypes. However, I intentionally didn't discuss an important subtype: Array. This month, I take a close look at what Array variables, or simply arrays, are and how you can create, fill, resize, traverse, erase, split, and join them. I also cover multidimensional and nested arrays.

Arrays in VBScript
Unlike all the other subtypes I showed you last month, an array can hold more than one value. An array lets you address many data values through the same variable. Think of an array as a list (e.g., a list of usernames). You reference each item in this list with a common name and index number. The common name is the name of the array variable. The common name typically includes the prefix arr to denote that the variable contains data of the subtype Array. The index number is an integer subscript that denotes an item's relative location in the list. The indexes always increment sequentially, starting from 0. For example, if an array has three items, the indexes are 0, 1, and 2. The 0 index represents the first position, the 1 index represents the second position, and the 2 index represents the third position in the array. . . .

Reader Comments
excellent article. Thanks a ton.

Shefali Sinha March 27, 2002


<p>How do you populate multidimensional arrays using Split() or Array()?</p>

Carola April 09, 2003


<P>An excellent article. I've just one question: Is there any neat way of checking if a dynamic array has had any values added to it or is empty? E.g., if you're reading a file into the resizable array but the file is empty.</P>

Simon April 12, 2003


<P>Wow, very impressive. Very descriptive and worthwhile article.</P>

David March 17, 2004


Wow, this is a great article. Very understandable and clear. I do have one question. From the research I've done you can have upto 60 dimensions assigned to a single array. Do you have any examples of 3 dimensional arrays and above - a graphic representation would be nice if you could point me to one. Thanks.

Amar Chhabra April 09, 2004


How do you get the UBound of the second dimension (width)? I use this for the UBound (height) UBound(arData, 2)

Pickles June 10, 2004


Just when I thought I knew everything about arrays... Great article.

Will July 01, 2004


Very informative, but unfortunately it didn't address my problem...how do you prepopulate the multi-dimentional array the way you did with the single dimension (ex. aArray=array("first","second","third")... to turn that into a 2 dimentional array, I'd like to say ReDim Preserve aArray(2,2) and add data to the second dimension the same way I populated the original dimension.

Anonymous User November 22, 2004


This is realy helpful
Thanks a lot!
Axel

Anonymous User December 08, 2004 (Article Rating: )


This is realy helpful
Thanks a lot!
Axel

Anonymous User December 08, 2004 (Article Rating: )


 See More Comments  1   2 

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

Have New Features Made Exchange Server Backups Unnecessary?

Cluster continuous replication and Volume Shadow Copy Service might have made backups unnecessary in Exchange 2007, but will admins feel comfortable without a dedicated backup solution in place? ...

Ballmer: Yahoo! No Bargain at Any Price

At Microsoft's annual shareholder meeting this week, CEO Steve Ballmer emphatically closed the door on the possibility that his company was interested in purchasing ailing Internet giant Yahoo!. His frank assessment of the situation sent Yahoo!'s stock ...


Related Events Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing