Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  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. . . .


Already a VIP member?
Please log on to view the full article

Why become a VIP member?

VIP-only online access
VIP CD delivered twice a year: offline access to the entire Windows IT Pro article library
Monthly issue of your choice of Windows IT Pro or SQL Server Magazine

Subscribe Now
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 be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
WinInfo Short Takes: Week of November 9, 2009

An often irreverent look at some of the week's other news, including some more Windows 7 sales momentum, some Sophos stupidity, Microsoft's cloud computing self-loathing, more whining from the browser makers, Zoho's "Fake Office," and much, much more ...

Command Prompt Tricks

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

Windows 7 Sets Sales Record

Microsoft CEO Steve Ballmer described Windows 7's first ten days of sales as "fantastic" while in Japan yesterday. ...


Scripting Whitepapers From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

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 Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


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 DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement