+ Reply to Thread
Results 1 to 5 of 5

keep the global variables

  1. #1
    Mike Archer
    Guest

    keep the global variables

    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

  2. #2
    Zone
    Guest

    re: keep the global variables

    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


  3. #3
    Bob Phillips
    Guest

    re: keep the global variables

    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
    >




  4. #4
    Tom Ogilvy
    Guest

    re: keep the global variables

    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


  5. #5
    Jim Thomlinson
    Guest

    re: keep the global variables

    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


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1