The Reset Command

  • Thread starter Thread starter JonWayn
  • Start date Start date
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?
 
Try:
RunCommand acCmdReset

Can't imagine a scenario where you would want to include this in a user
application though.
 
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.
 
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
 
Back
Top