|
-
February 10th, 2000, 12:41 AM
#1
General Declarations
what is the declarations for? i dont get it, i have only read one vb book.
-
February 10th, 2000, 01:17 AM
#2
Re: General Declarations
The general declaration is used to declare variables who must be accessible from within the form/module it is in(DIM), or withing the entire project(PUBLIC).
Like if you had this code:
'public declarations
Dim s as Integer
public sub Command1_Click()
'button 1 is pressed
t = t + 1
msgbox t
End Sub
public sub Command2_Click()
'button 2 is pressed
s = s + 1
msgbox s
End Sub
This would result in that when you press button 1, 1 is added to T, but because T isn't declared, it's value is cleared whenever the program leaves the sub, in this case after the messagebox. This results in t always being 1 when button 1 is clicked.
However, pressing button 2 will result in 1 being added to s. The value of S will remain the same when the program exits the sub. So when it enters the sub for a second time, it's value will be 2.
Tom Cannaerts
[email protected]
The best way to escape a problem, is to solve it.
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
|