Clearing memory

yes, but you cannot get past this bit of code without either modifying the statement or Ending the program.

Exactly. When encountering a break during debugging I regularly comment out or add a line to jump the offending part of the code and press the go button so I can continue with the state preserved.

It saves a hell of a lot of time in debugging. If the error affected the variables then that would not be possible.

It is important to realise that it is the reset not the error that affects the variables. Without knowing that, the possibility of modifying the code while in the break would not be evident.
 
Haha I'm glad I stumbled on this post today I needed the laugh! (I don't mean this in a bad way) You guy's are great and this forum wouldn't be much without all of you. So just putting out a big thanks to everyone that has posted here trying to help others understand.

A little off topic but who cares :D
 
And another thing which make the often quoted advice utter nonsense…

The reset might happen when we come out of debug mode.
In an MDE file we can’t go into debug mode and so we can’t come out of debug mode.
Since we can’t come out of debug mode the reset does not happen.
Since the reset does not happen, the value of Global variables is not lost.

Behind a Form:-
Code:
Public A As Long


Private Sub cmdTest_Click()
    Dim B As Long
    
    MsgBox "Before error : " & A
    
    A = 10
    
    B = A / 0

End Sub
You can move Public A As Long to a standard module if you like, it makes no difference.
Run it more than once.
A gets reset in an MDB file but not in an MDE file.
The end user should be running an MDE file not an MDB file.

So the often quoted statement that…
“Global variables can lose their value when an unhandled error occurs.”
is utter nonsense because the people who quote such things don’t know the difference.

All it is, is people repeating stuff which they have read but they do not have any specific knowledge on the subject. They may have ”ghostly memories” of something happening in the past (OK, it’s difficult to have memories of the future) but can they reproduce that memory?

Chris.
 

Users who are viewing this thread

Back
Top Bottom