How do I reset a program to its initial state

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My program has several global arrays declared but not sized: Public Shared A
As Double(,), Public Shared B As Double(,), etc.

As methods are called the arrays are sized as appropriate for specific
circumstances. As time goes by, memory gets used and things sometimes bog
down. I would like to be able to reset my program to its initial state with
some kind of "clear" subroutine.

I have tried something like this:
Dim blank(1, 1) As Double
A = (blank)
B = (blank)
C = (blank)

And it helps but doesn't really do enough sometimes and I have to quit and
start-up again.

Is there a way to reinitialize everything without closing the application
and starting up again?
 
Mark,

Visual Basic's Erase command will clear arrays and free their memory.

I think you can also assign a value of Nothing to the array to accomplish
the same thing.

Kerry Moorman
 
mark said:
My program has several global arrays declared but not sized: Public Shared
A
As Double(,), Public Shared B As Double(,), etc.

As methods are called the arrays are sized as appropriate for specific
circumstances. As time goes by, memory gets used and things sometimes bog
down. I would like to be able to reset my program to its initial state
with
some kind of "clear" subroutine.

Assign 'Nothing' to the array variable. I suggest to take a look at the
'Erase' statement too.
 
Mark,

If it is a form or a component, than you can probably achieve what you want
by looking how to reuse the
InitializeComponent()

in the designer part

You have to remove of course than first every control from the form.

http://msdn.microsoft.com/library/d...mscontrolcontrolcollectionclasscleartopic.asp

Me.controlcollection.clear

I never did it however when I once told this to somebody else he wrote back
that it was working very well for him.

I hope this helps,

Cor
 

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

Back
Top