bottom
Great WordTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > WordTips Home > Macros > Quickly Dumping Array Contents

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.

Helpful Links

Ask a Word Question
Make a Comment

Tips.Net Home
Vital News Home

WordTips FAQ
WordTips Premium

Learn Access Now

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

Advertise on the
WordTips Site

 

Great Info!

Get tips like this every week in WordTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)