The Reset Command

J

JonWayn

How do you programatically do what the Reset command on the Visual Basic
toolbar, which is displayed while a module is open, of course, does?
 
A

Allen Browne

Try:
RunCommand acCmdReset

Can't imagine a scenario where you would want to include this in a user
application though.
 
J

JonWayn

I've got programs that the user may rerun, without closing between runs, and
I just want to ensure that everything is reset. I have had experience before
where collection objects undesirably retain members added from a previous
run of the program.
 
T

TC

By "program", I assume you mean, a public procedure or function in a
standard module?

A collection (or any other variable) will only retain its previous value, if
it is declared globally to the procedure you're running, or is declared
Static within that procedure (which is much the same thing). There really
shouldn't be any need to reset the environment, before you run the procedure
again.

If a collection is declared globally, and retains its previous values, but
you do not want that to happen, just move its declaration inside the
procedure that uses it. If it is used by *several* procedures, pass it
around as a parameter. Alternatively, just reset it in code at the start of
the main procedure (set blah = new collection).

Resetting the environment is not the appropriate way to do what you want.

HTH,
TC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top