Hello - When VBA code chokes and the user selects the debug button, all
global variables are cleared. It there a way to keep the global variable
values or an option other than global variables?
--
Thanks,
Mike
Hello - When VBA code chokes and the user selects the debug button, all
global variables are cleared. It there a way to keep the global variable
values or an option other than global variables?
--
Thanks,
Mike
I use a separate spreadsheet to store variables I want to keep after
breaking the program. Anyway, I don't think I've ever run into this
problem. If I use this code
Dim myGlobal as string
Sub Huhoh
myGlobal="still here"
msgbox 0/0
End Sub
myGlobal still keeps its string in Debug.
James
He means on a subsequent run the variable is cleared.
--
HTH
Bob Phillips
(remove xxx from email address if mailing direct)
"Zone" <jkend69315@aol.com> wrote in message
news:1146679688.713552.183610@i39g2000cwa.googlegroups.com...
> I use a separate spreadsheet to store variables I want to keep after
> breaking the program. Anyway, I don't think I've ever run into this
> problem. If I use this code
>
> Dim myGlobal as string
>
> Sub Huhoh
> myGlobal="still here"
> msgbox 0/0
> End Sub
>
> myGlobal still keeps its string in Debug.
>
> James
>
Why not write a routine to initialize your global variables. In you code,
have a global variable that is dedicated to just checking
Public gbChecker as Boolean
Initialize it to true in the workbook_open event.
if gbChecker = False then
' run code to init variables
end if
Better is to handle errors so the user never sees an error message displayed
by the system unless it is fatal.
--
Regards,
Tom Ogilvy
"Mike Archer" wrote:
> Hello - When VBA code chokes and the user selects the debug button, all
> global variables are cleared. It there a way to keep the global variable
> values or an option other than global variables?
> --
> Thanks,
> Mike
There is no way to hold on to the variables short of storing them in a
worksheet somewhere. When the execution is halted the memory that stores the
variables is automatically cleared. In the grander scheme of things if you
just had an error though you can not gurantee that the values in your globals
would be correct anyways so clearing them is really no great loss. What you
want to do is to write bullet proof code with a robust error handler to
gracefully handle anything that is thrown at it. That will keep you from
getting to the debug screen in the first place.
--
HTH...
Jim Thomlinson
"Mike Archer" wrote:
> Hello - When VBA code chokes and the user selects the debug button, all
> global variables are cleared. It there a way to keep the global variable
> values or an option other than global variables?
> --
> Thanks,
> Mike
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks