Results 1 to 6 of 6

Thread: Using global variables

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Hendersonville , NC
    Posts
    260

    Using global variables

    What is the best way of sharing common data (example - an order number) between multiple forms? I have tried a global class but values get re-initialized between forms...

    I have tried property bags but can not get then to be "seen" fetween forms...

    gollnick
    William E Gollnick

  2. #2
    Addicted Member
    Join Date
    Sep 2003
    Posts
    227
    create a module and declare your global variables there

  3. #3
    Lively Member
    Join Date
    Oct 2003
    Posts
    88
    That's what I do also.

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    An OOP approach would mean you'd have an order object that gets passed around. Maybe even a process class, something like FillOrder to maintain state during a new order.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Hendersonville , NC
    Posts
    260
    I created a global module but I lose scope from from to form. In other words .. what I assign to a global variable in form1 coes to me as blanks when I grab it in form2. I DIM the class but when I do it as NEW ... alls gone.
    William E Gollnick

  6. #6
    Lively Member
    Join Date
    Oct 2003
    Posts
    88
    That makes sense, because when you New anything, you reinitialize it. Don't do that. Just declare your variables in the module and set them as you go, and as long as one of the forms from your app stays open, the variables in the module should persist. Works that way for me anyhow...

Posting Permissions

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



Click Here to Expand Forum to Full Width