Results 1 to 21 of 21

Thread: Global vs. Public

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Question

    Greetings.

    What's the difference between these 2 (Global and Public) when it comes to declaring variables?

    Thanks.

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    No difference (other than "Public" is the preferred term). "Public" was introduced in VB5, I believe, and "Global" will eventually be phased out...

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    No actual difference, but
    You can only declare a global variable in a standard module, while public can be declared in both standard modules and classes
    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.

  4. #4
    Addicted Member
    Join Date
    May 2000
    Posts
    240

    Not much difference..

    They both do the same thing basically....
    Am not totally sure if public just allows you to use the variable in one form or in the entire project..but i know global does...

  5. #5
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Use PUBLIC and don't bother learning GLOBAL because it is getting obsoleted in Visual Basic 7. Like everyone here said, it is the same concepts.
    Chemically Formulated As:
    Dr. Nitro

  6. #6
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    Ah, yes, but 'Global' makes your application sound so much more powerful
    Courgettes.

  7. #7
    Guest
    The Global keyword is only kept for backwards compatibility.

  8. #8
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    I forgot what I was going to write.
    .
    .
    .
    Oh yeah, oh wait lost it, I need globals in my head!
    Well, you don't need a module for a global but in seperate forms you don't have to put module1.myglobal like you have to use form1.mypublic.

    Shouldn't this topic be in chit-chat or the like?

  9. #9
    Junior Member
    Join Date
    May 2000
    Location
    Alaska
    Posts
    21

    Question

    This is VB related. Why would it have to be in the Chit Chat? The thread is seeking information on Public and Global keyword.
    Alaska

  10. #10
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    This isn't a problem is it? It seems more like it's asking peoples opinions.

  11. #11
    Junior Member
    Join Date
    May 2000
    Location
    Alaska
    Posts
    21
    Originally posted by OneSource
    Greetings.

    What's the difference between these 2 (Global and Public) when it comes to declaring variables?

    Thanks.
    It is a problem when the person doesn't know the difference between the two. Don't know which one to use.

  12. #12
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Exactly, he said, "what's the difference". He didn't say, "I don't know which to use".

    You can quote him but not read what he said. Sad.

  13. #13
    Junior Member
    Join Date
    May 2000
    Location
    Alaska
    Posts
    21
    Hey Bud!

    Lets not head into that route with the sad comment!

    This is a VB related question and he is asking about something he is not sure about which means he doesn't know.

    It is not a topic about Evolution or anything else.

  14. #14
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    He has more posts than you.

  15. #15
    Junior Member
    Join Date
    May 2000
    Location
    Alaska
    Posts
    21

    Talking

    We are going to play the post count game now,then Yes he does and comparing to this account only. My other account has 5 times more posts than him.

  16. #16
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    If you want to continue take it to chit-chat, I don't want to be a hypocrite.

  17. #17
    Junior Member
    Join Date
    May 2000
    Location
    Alaska
    Posts
    21
    That is the point I was about to make and besides what we are talking about posts count has nothing to do with this thread.

    See you around man.
    Alaska

  18. #18
    Guest
    Tyler, is correct. This is a VB topic, however, DigialError, it seems that you guys are turning it into a Chat topic. ;-}

    To prevent this thread from getting out of hand, I suggest that future viewers refer to the following thread for more information.

    http://forums.vb-world.net/showthrea...threadid=19372

  19. #19
    Guest

    Question Surely there must be a difference

    As some one stated Global can not be declared on a form yet Public can. Therefore there is at least one difference.

    How about this, (haven't tried it..friday afternoon the first beer is cooling down), if you declare a Public variable in a sub form, (i.e a form called from another form), and declare a Public variable in the sub-form will that variable be available to the calling form. Megatron sounds like he would know the answer to this one

    Global and Public sound like the old dbase variable types. I vaguely remember that in dbase if you declared a Public variable in a called routine it wasn't available to the calling routine, but was available to routines below the called routine. Whereas a Global variable become available to all routines.

    Maybe Microsoft were intending to do something similar, and then thought "What a completely stupid idea", having debugged a number of dBase systems l can concur on that.

  20. #20
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221

    Jethro calling me some one

    but that's not the difference, that's what makes Global useless.

    Here's a qwestion for Sam, do you put property Get/Let's instead of Public variables on the form? It's a class too.
    if you declare a Public variable in a sub form, and declare a Public variable in the sub-form will that variable be available to the calling form
    Cool Jethro, you put 2 public variables on a sub form, and they will be both available to the calling form

    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.

  21. #21

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Thumbs up Thanks, everyone ...

    although we degenerated into a little chit-chat for a while.

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