|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
New to VB. a question about global level variables
I am just starting in VB. I do not understand what a "global level variable" has to do with the modules window? and why should it only be included in 1 module? I hope I do not get flamed for this post.
Rich |
|
#2
|
||||
|
||||
|
Global level variables are accessible from anywhere within you application.
There for it is always good practice to declare them within a module. |
|
#3
|
|||
|
|||
|
You only declare global variables in a single module, due to the scope of that variable. Eg;
Public g_sMyGlobalString As String Because you are declaring in a module with the Public syntax, as Memnoch says it is then accessible from anywhere else in your project. I usually create a 'basDeclares' module - stick all my Global API's, Constants, Variables etc in that...then you always know where they are! Always try and code to the lowest possible scope, avoid GVs where possible (tho of course you do need them!), just don't go down the route of creating unnescessary global's because it's easier, becomes confusing in larger apps. |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > New to VB. a question about global level variables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|