Clearing an array?

Would it be possible for someone to help explain how to clear an array of values currently stored in it. Would you go through the array line by line and write = "" or would you use to ReDim statement. Any help would be greatly appreciated.


  • I'm not sure how later versions of VB handle it, but you might try the Erase function. If the array is static, the function will clear the value of each element; if the array is dynamic, it will destroy the elements.

  • [color=Blue]ReDim[/color] array(X)
    with X being the size of your array - 1 (Programming Languages start at 0 not 1)

    use a for...Next Loop

    [color=Blue]For[/color] X [color=Blue] as integer[/color] = 0 to (Array().length - 1)
    Array(X) = [color=Blue]Nothing[/color]

    [color=Blue]ReDim Preserve [/color]Array(X)

    this will Keep all values and just resize the array. with X being the size of the new array - 1
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!