Results 1 to 5 of 5

Thread: Declaring Global?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    I dont really understand this and
    I was hoping someone could explain
    this to me.

    For the use through all of my form
    I would declare a variable "Public".
    It seems to work fine! Whats the
    point of declare a variable "Global".
    Besides Private, Dim, Public, And
    Global are there any other ways to
    declare variables?

    thanks!

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    No point to use Global since Public does the same, it's for backward compability, Private variables can also be declared with Dim, can't be accessed from outside that module. Dim is used mostly to declare variables with procedure scope, you declare them inside a function or sub, Also there's static variables which you declare static within a procedure. Their values will remain when you exit the function and not be instanced everytime you call it. Can be usefull sometimes for recursion.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Thanks..

    Sounds like all you need is Private
    and public.
    Whats the point in using static,
    or global!
    Static if im correct will stay in
    memory as long at the program is
    running right? So why not just use
    a public?

  4. #4
    Guest
    Global was used in earlier versions of VB but was replaced by Public in VB4.

    The only reason Global is still around is so that you can load previous VB projects into newver VB projects.
    (called backwards compatibility)

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Static variables won't be initialized until the line is fired. It will unload if the object it exist in unloads.
    Static variables are also declared at procedure level so you won't need to put it topmost, also use private instead of public as often as you can, that will save you performance.
    Also, in fact, it's Dim and Public not Private and public that is the only ones you actually need.

    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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