Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 18011
Number of posts: 55384

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Clearing an array? Posted by CookieMonster on 17 Apr 2011 at 5:47 AM
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.
Report
Re: Clearing an array? Posted by pseudocoder on 18 Apr 2011 at 8:51 PM
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.


Report
Re: Clearing an array? Posted by JTB600A on 2 May 2011 at 12:54 PM
ReDim array(X)
with X being the size of your array - 1 (Programming Languages start at 0 not 1)

or
use a for...Next Loop

For X as integer = 0 to (Array().length - 1)
Array(X) = Nothing
Next

ReDim Preserve Array(X)

this will Keep all values and just resize the array. with X being the size of the new array - 1



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.