By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,827 Members | 2,220 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,827 IT Pros & Developers. It's quick & easy.

how to clear an array dynamically

chandru8
100+
P: 145
i have cleared the array by assigning null value can anyone suggest me to clear the array
Jan 23 '08 #1
Share this Question
Share on Google+
2 Replies


P: 58
Expand|Select|Wrap|Line Numbers
  1. Sub Clear_Array()
  2.    Dim arr(2) As String
  3.  
  4.    arr(1) = "Hello"
  5.    arr(2) = " World"
  6.  
  7.    Debug.Print ">" & arr(1) & arr(2) & "<"
  8.  
  9.    Erase arr
  10.  
  11.    Debug.Print ">" & arr(1) & arr(2) & "<"
  12. End Sub
  13.  
Jan 23 '08 #2

Expert 5K+
P: 8,434
the term "clear" is a bit vague - it may mean either of two things.

Assuming this is VB6 (don't know about later versions) you can use Erase to completely remove the array (so it no longer exists, doesn't take up any memory and cannot be used) or ReDim to simply clear the values but otherwise leave the array intact.
Jan 24 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.