triplemaya
Member
- Joined
- Aug 27, 2006
- Messages
- 15
- Programming Experience
- Beginner
I have an object - UpTime - which keeps track of elapsed time using a standard timer. This is instantiated in the main program flow. Under certain conditions the user is given an option to start again, in a dialog box, and then the timer needs to be zeroed. The problem is that when the ok button is pressed, the program is off in the OK Button Click code of the dialog box, and from there I can't access the instance of the UpTime object. My apologies for this very basic question, but could someone please show me how to do this.
I have declared a shared function reset() in the UpTime class, which the OK Button Click code can call, but this, of course, cannot access instance members without a reference to the instance. In another language I could declare a static variable, say, doReset, and then the instance can check this variable at every access of the internal data, but "static is not valid on a member variable declaration" - squiggly line - so that's out. Besides, that doesn't seem very satisfactory. Equally I can write to the registry and then check that from within UpTime with every access, but that is pretty horrible also.
Declaring the instance of UpTime Public and / or Shared doesn't make it visible in the other module, though at microsoft the visibility of Public variables is stated as
" Anywhere in or outside of a project".
My declaration of the instance is
#Region "Global Variables"
Dim upTime as new UpTime()
I have declared a shared function reset() in the UpTime class, which the OK Button Click code can call, but this, of course, cannot access instance members without a reference to the instance. In another language I could declare a static variable, say, doReset, and then the instance can check this variable at every access of the internal data, but "static is not valid on a member variable declaration" - squiggly line - so that's out. Besides, that doesn't seem very satisfactory. Equally I can write to the registry and then check that from within UpTime with every access, but that is pretty horrible also.
Declaring the instance of UpTime Public and / or Shared doesn't make it visible in the other module, though at microsoft the visibility of Public variables is stated as
" Anywhere in or outside of a project".
My declaration of the instance is
#Region "Global Variables"
Dim upTime as new UpTime()