|
-
May 2nd, 2001, 12:38 PM
#1
Thread Starter
PowerPoster
Module1 BasicQuestion
BasicQuestion:
If I place this code into a standard module then am I right in saying that variable conn is available to all forms, classes in the project?
Option Explicit
Public Conn As ADODB.Connection
-
May 2nd, 2001, 12:42 PM
#2
PowerPoster
-
May 2nd, 2001, 12:42 PM
#3
_______
<?>
Code:
Variables declared using the Public statement are available to all procedures in all modules in all applications unless Option Private Module is in effect; in which case, the variables are public only within theproject in which they reside.
Caution The Public statement can't be used in a class module to declare a fixed-length string variable.
Use the Public statement to declare the data type of a variable. For example, the following statement declares a variable as an Integer:
Public NumberOfEmployees As Integer
Also use a Public statement to declare the object type of a variable. The following statement declares a variable for a new instance of a worksheet.
Public X As New Worksheet
If the New keyword is not used when declaring an object variable, the variable that refers to the object must be assigned an existing object using the Set statement before it can be used. Until it is assigned an object, the declared object variable has the special value Nothing, which indicates that it doesn't refer to any particular instance of an object.
You can also use the Public statement with empty parentheses to declare a dynamic array. After declaring a dynamic array, use the ReDim statement within a procedure to define the number of dimensions and elements in the array. If you try to redeclare a dimension for an array variable whose size was explicitly specified in a Private, Public, or Dim statement, an error occurs.
If you don't specify a data type or object type and there is no Deftype statement in the module, the variable is Variant by default.
When variables are initialized, a numeric variable is initialized to 0, a variable-length string is initialized to a zero-length string (""), and a fixed-length string is filled with zeros. Variant variables are initialized toEmpty. Each element of a user-defined type variable is initialized as if it were a separate variable.
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
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
|