|
-
Apr 18th, 2007, 12:09 AM
#3
Re: [2005] Can variables in private sub be used outside ??
Local variables are not accessible outside the block in which they are declared. If you declare a variable inside a method then outside that method that variable simply doesn't exist. You can declare another variable in another method with the same name but those two variables are not related in any way whatsoever. If you need a variable to be accessible from two independent blocks then the variable must be declared outside both of them. If those blocks are methods then the variable must be declared at the class-level or equivalent.
Note that by "block" I mean any section of code that starts at one line and ends at a corresponding End statement or the like, like Function...End Function, If...End If, For...Next, etc.
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
|