You need to declare boolStopPressed scoped to the module or whatever this code is in.
You should also use
at the top of the module to require all variables be declared before use (If you do, this will cause compiler errors when you try to run the code, until all are declared).
The problem is boolStopPressed is never explicitly declared so when you use it in btnStart_Click it is created but only local to that procedure. The same in btnStop_Click, that copy of the variable is local to the procedure btnStop_Click so they can never 'interact'.
I've no idea what dteStopped or dteElapsed are supposed to do, but the same applies. If they are referenced in separate procedures then they must be in scope for those procedures, not local to them.
Bookmarks