By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,649 Members | 2,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,649 IT Pros & Developers. It's quick & easy.

How do I reset a program to its initial state

P: n/a
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 b
Dec 6 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" wrote:
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 b

Dec 6 '05 #2

P: n/a
"mark" <ma**@discussions.microsoft.com> schrieb:
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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 6 '05 #3

P: n/a
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/de...cleartopic.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


"mark" <ma**@discussions.microsoft.com> schreef in bericht
news:F0**********************************@microsof t.com...
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 b

Dec 7 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.