Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.

Comments

  • pseudocoderpseudocoder Posts: 673Member ✭✭
    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.


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

    or
    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]Next[/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.