|
-
May 6th, 2000, 03:33 AM
#1
Thread Starter
Member
I apologize if this info is redundant - I'm new here.
It makes sense to name globals with a unique symbol/qualifier/etc so that others reading your code know the variable is global...something like g_CustomerName
You can take this concept one step further by creating a type structure in a code module, and put all variables you want to be global in the structure...
'Put all variables you want to be global in the type structure
Type GlobalVariables
InvoiceNumber as integer
InvoiceDate as date
CustomerID as string
...
...
... define all other globals here
...
...
End Type
'Now define a variable as the new structure
Public g as GlobalVariables
Now anytime you want to reference a global variable, just type g.(variable name) like...
g.InvoiceNumber = 12345
g.InvoiceDate = now()
and so on and so on. What's nice is that anytime you type g. to reference a global, the menu appears with all the variables. Now you don't have to memorize exactly what you called each variable. You can just select it from the list.
I'm not sure how this method effects efficiency.
Peace
-
May 6th, 2000, 04:21 AM
#2
Hello,
Neet idea, I'll give it a try.
Best,
-
May 6th, 2000, 04:44 AM
#3
Frenzied Member
That's what you're "supposed" to do, it's a good tip, you should technicly do it with a class module rather than a type though, then you can put verification code on your variables.
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
|