
Tips.Net > WordTips Home > Macros > Quickly Dumping Array Contents
Summary: A VBA macro that will erase all of the information in your array. (This tip works with Microsoft Word 97, Word 2000, Word 2002, and Word 2003.)
If you have done any programming in VBA, you know the value of using variable arrays to store information. It is not uncommon to start working with large arrays in your macros. For instance, you might declare a 100-element string array, as follows:
Dim MyText(99) As String
As your macro executes, information can be stored and restored in the elements of the array. At some time, you may want to erase all the information in the array. One classic way of doing this is using a For ... Next loop to step through each array element, as follows:
For J = 0 To 99
MyText(J) = ""
Next J
When the looping is complete, everything has been erased from the array. A quicker way of accomplishing the same task is to use the ERASE function, as follows:
Erase MyText
Once executed, this single line sets each element of the MyText array back to an empty string. If the array is numeric, then each element of the array is set to zero.
Tip #1444 applies to Microsoft Word versions: 97 2000 2002 2003
Find and Replace Almost Anything! Learn the ins and outs of the powerful search engines available in Word. Learn to search for and replace text, formatting, graphics, and special characters the easy way with WordTips: Find and Replace.
Do you want a decade of WordTips information at your fingertips? You can find what you need with the WordTips Ten-Year Library. (more information...)
Ask a Word Question
Make a Comment
Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Pet Tips
Word2007 Tips
WordTips