Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable scope 1

Status
Not open for further replies.

richardii

Programmer
Jan 8, 2001
104
GB
Please could someone explain why it is that when you declare a variable as Public, and you assign that variable (with 10 in this case), it is not visible as 10 throughout the module or in other modules. It seems you have to assign it within a module, which seems to defeat the point of the variable being public. Assignment is invalid outside a Procedure.

So how would I declare (and assign) a varibale that can be seen by all procedures?


 
you need to make it Global

put this in a module in the declarations section

Global yourVariable
DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Thanks - it seems odd to me that you can't assign variables a value outside a procedure - but thinking about it, it's perhaps a good idea!
 
And if you just need it to have a scope of the module,
declare it per normal within the module, but outside
the procedure. <insert witticism here>
codestorm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top