|
-
Jun 14th, 2000, 04:00 AM
#15
More clarification
Jaguar is right when he says that this problem arises from VB's attempt to implement object-oriented programming .
For those of you who program in C++:
When you make a form in VB, you are creating a new class (ie. frmMyNewForm) which "inherits" from the Form class. frmMyNewForm does everything that a standard form does, but it adds it's own functions (private, protected, and public) and its own variables (also private, protected, and public).
It's accurate enough for this discussion to think of each form as an instance of it's own class. By declaring a Public variable in a form, *you are making it a member of that class* and giving other classes (other forms) "permission" to use it. (Judd- this is why you need the extra indirection).
The reason you can't declare a Global in a form is because a global class member doesn't make any sense (What if there is no instance of the class, ie. the form is Unloaded?) The reason you can put a Public variable in a module is simply to minimize the mistakes that a VB programmer can make. The compiler will handle it just like a Global.
Anyway, moral of the story is that they'll work the same in VB, they just have different origins.
[Edited by RoyceWindsor1 on 06-14-2000 at 05:03 PM]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|