how to clear an array dynamically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chandru8
    New Member
    • Sep 2007
    • 145

    how to clear an array dynamically

    i have cleared the array by assigning null value can anyone suggest me to clear the array
  • WinblowsME
    New Member
    • Jan 2008
    • 58

    #2
    [CODE=vb]
    Sub Clear_Array()
    Dim arr(2) As String

    arr(1) = "Hello"
    arr(2) = " World"

    Debug.Print ">" & arr(1) & arr(2) & "<"

    Erase arr

    Debug.Print ">" & arr(1) & arr(2) & "<"
    End Sub
    [/CODE]

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      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.

      Comment

      Working...