|
|
|
Statement
|
What It Does
|
Comments
|
|
[Public|Private] Const constname_
[As type] = expression
|
Declares a constant with the name constantname and assigns it the value of expression
|
If As type is missing, the constant will be assigned a data type matching that of expression
|
|
[Public|Private]Declare Sub name _
Lib "libname" _
[Alias "aliasname"] _ [arglist]
|
Declares references to Sub or Function procedures in an external DLL (dynamic-link library).
|
Public and Private define the procedure's scope. name is the procedure's name, and libname specifies the DLL containing the procedure. aliasname specifies an alternate name for the procedure in the DLL. arglist is an argument list passed to the procedure. For Function procedures, the As type specifies the data type of the value returned by the Function. Declare statements can only be used at module level.
|
|
DefBool letterrange[, letterrange]. . .
|
Declares all variables and function return values beginning with the letters specified by letterrangeare automatically defined as Boolean
|
Each letterrange should be constructed as letter1[-letter2], where letter1 is the first (or only) letter in the range, and letter2 is the last letter in the range. DefBool can only be used at module level.
|
|
DefByte letterrange[, letterrange]. . .
|
Declares all variables and function return values beginning with the letters specified by letterrange are automatically defined as Byte
|
Each letterrange should be constructed as letter1[-letter2], where letter1 is the first (or only) letter in the range, and letter2 is the last letter in the range. DefByte can only be used at module level.
|
|
DefCur letterrange[, letterrange]. . .
|
Declares all variables and function return values beginning with the letters specified by letterrange are automatically defined as Currency
|
Each letterrange should be constructed as letter1[-letter2], where letter1 is the first (or only) letter in the range, and letter2 is the last letter in the range. DefCur can only be used at module level.
|
|
DefDate letterrange[, letterrange]. . .
|
Declares all variables and function return values beginning with the letters specified by letterrange are automatically defined as Date
|
Each letterrange should be constructed as letter1[-letter2], where letter1 is the first (or only) letter in the range, and letter2 is the last letter in the range. DefDate can only be used at module level.
|
|
DefDbl letterrange[, letterrange]. . .
|
Declares all variables and function return values beginning with the letters specified by letterrange are automatically defined as Double
|
Each letterrange should be constructed as letter1[-letter2], where letter1 is the first (or only) letter in the range, and letter2 is the last letter in the range. DefDbl can only be used at module level.
|
|
DefDec letterrange[, letterrange]. . .
|
Declares all variables and function return values beginning with the letters specified by letterrange are automatically defined as Decimal
|
Each letterrange should be constructed as letter1[-letter2], where letter1 is the first (or only) letter in the range, and letter2 is the last letter in the range. DefDec can only be used at module level.
|
|
DefInt letterrange[, letterrange]. . .
|
Declares all variables and function return values beginning with the letters specified by letterrange are automatically defined as Integer
|
Each letterrange should be constructed as letter1[-letter2], where letter1 is the first (or only) letter in the range, and letter2 is the last letter in the range. DefInt can only be used at module level.
|
|
DefLng letterrange[, letterrange]. . .
|
Declares all variables and function return values beginning with the letters specified by letterrange are automatically defined as Long
|
Each letterrange should be constructed as letter1[-letter2], where letter1 is the first (or only) letter in the range, and letter2 is the last letter in the range. DefLng can only be used at module level.
|
|
DefObj letterrange[, letterrange]. . .
|
Declares all variables and function return values beginning with the letters specified by letterrange are automatically defined as Object
|
Each letterrange should be constructed as letter1[-letter2], where letter1 is the first (or only) letter in the range, and letter2 is the last letter in the range. DefObj can only be used at module level.
|
|
DefSng letterrange[, letterrange]. . .
|
Declares all variables and function return values beginning with the letters specified by letterrange are automatically defined as Single
|
Each letterrange should be constructed as letter1[-letter2], where letter1 is the first (or only) letter in the range, and letter2 is the last letter in the range. DefSng can only be used at module level.
|
|
DefStr letterrange[, letterrange]. . .
|
Declares all variables and function return values beginning with the letters specified by letterrange are automatically defined as String
|
Each letterrange should be constructed as letter1[-letter2], where letter1 is the first (or only) letter in the range, and letter2 is the last letter in the range. DefStr can only be used at module level.
|
|
DefVar letterrange[, letterrange]. . .
|
Declares all variables and function return values beginning with the letters specified by letterrange are automatically defined as Variant
|
Each letterrange should be constructed as letter1[-letter2], where letter1 is the first (or only) letter in the range, and letter2 is the last letter in the range. Defvar can only be used at module level.
|
|
Dim [WithEvents] varname(subscripts) _
[As[New]type] [,[WithEvents] _
varname(subscripts) [As[New] type]]...
|
Declares one or more variables or objects.
|
varname is the variable name, and As [New] type (optional) indicates its data type. If New is used, then an implicit creation of the object is made. WithEvents (optional) valid only when the Dim statement is used in class modules indicates varname is an object variable that responds to events triggered by an ActiveX object. subscripts (optional) are the dimensions of an array variable.
|
|
[Public|Private] Enum namemember-1_
[= constantexpression] member-2_
[= constantexpression] _
...
|
Declares name an enumeration composed of one or more members (member-1, member-2,
. . . , member-n )
|
Members can be assigned values using constantexpression. Public and Private (optional) define the enumeration's scope.
|
|
[Public]Event procname[(arglist)]
|
Declares a user-defined event with the name specified by procname.
|
Public indicates the Event will be visible throughout the project (the default). (arglist) (optional)should contain one or more arguments defined using the syntax:
[ByVal | ByRef]varname _
[As type]
where varname is the argument name, As type is the data type of the argument, and (optional) ByRef or ByVal specify whether the argument should be passed by reference or by value. If ByRef and ByVal are not specified, then the argument will be passed by reference. (In VB.NET, the argument will be passed ByVal)
|
|
[Public|Private|Friend] _
[Static]Function name (arglist)[As type] _
[statements]
[name = expression]
[Exit Function]
[statements]
[name = expression]
End Function
|
Declares the various parts of a Function procedure..
|
(optional) Public,Private, and Friend are used to define the Function's scope, and (optional) Static indicates that the procedure's local variables are preserved between calls to the Function. name specifies the Function procedure and is assigned a value (name = expression) that's returned by the procedure. As type specifies the return value's data type. (optional) Exit Function is used to immediately exit the Function procedure. (optional) arglist defines the arguments that will be passed to the procedure. Arguments use the following syntax:
[Optional] _
[ByVal|ByRef] _ [ParamArray] _
varname() [As type] _
[=default value]
where Optional specifies that the argument is not required (default value assigns the argument's default), ByVal and ByRef determine whether the argument is passed by value (default in VB.NET) or by reference (default in VB6), and ParamArray specifies that the argument is an Optional array of Variant elements. ParamArray is only used with the last argument in the argument list.
|
|
Implements[interfacename|class]
|
Specifies an interface (interfacename) or class (class) that ll be used in the class module where the Implements statement is used.
|
|
|
Option Compare(Binary|Text|Database)
|
Declares the default method used for string comparisons.
|
Option Compare can only be used at module level.
|
|
Option Explicit
|
Forces all variables to be explicitly declared in Dim statements
|
|
|
Option Private
|
Prevents a module's contents (i.e., variables and objects) from being used outside its project.
|
Option Private is only necessary when working with host applications that allow variables and objects to be referenced across multiple projects.
|
|
Private [WithEvents] _
varname(subscripts) _
[As[New]type] [,[WithEvents] _
varname(subscripts) _
[As[New]type]]...
|
Declares one or more Private variables. Triggered by an ActiveX object. The Private statement can only be used at module level, and variables declared with it cannot be used outside their own module.
|
varname specifies the name of the variable being declared, and subscripts are the array variable's dimensions. As [New] type (optional) is used to specify the variable's data type, with New enabling implicit creation of an object. WithEvents (optional) specifies that the variable being declared is used to respond to events
|
|
[Public|Private|Friend] [Static] _
Property Get name [(arglist)][As type]
[statements]
[name = expression]
[Exit Property]
[statements]
[name = expression]
End Property
|
Declares the various parts of a Property Get procedure, which is used to obtain the value of a property.
|
(optional ) Public, Private, and Friend keywords define the procedure's scope, and (optional) Static states that the procedure's local variables are to be preserved between procedure calls. name specifies the property to be retrieved and is assigned a value (name =expression) to be returned as the property's value. The property's data type is specified using As type. (optional) Exit Property is used to immediately exit the Property Get procedure. The optional (arglist) defines the arguments that will be passed to the procedure. Those arguments should use the following syntax:
[Optional] [ByVal|ByRef] _ [ParamArray] varname[()] _
[As type] [=default value]
where Optional specifies the argument is not required (default value assigns the argument's default), ByVal and ByRef indicate the argument is to be passed by value (default in VB.NET) or by reference (default in VB6), and ParamArray specifies the argument is an Optional Variant array . ParamArray is only used with the last argument in the argument list.
|
|
[Public|Private|Friend] _
[Static]Property Let name([arglist,]value)
[statements]
[ExitProperty]
[statements]
End Property
|
Declares the various parts of a Property Let procedure, which is used to obtain the value of a property.
|
(optional ) Public, Private, and Friend keywords define the procedure's scope, and (optional) Static states that the procedure's local variables are to be preserved between procedure calls. name specifies the property to be retrieved and is assigned a value (name =expression) to be returned as the property's value. The property's data type is specified using As type. (optional) Exit Property is used to immediately exit the Property Let procedure. The optional (arglist) defines the arguments that will be passed to the procedure. Those arguments should use the following syntax:
[Optional] [ByVal|ByRef] _ [ParamArray] varname[()] _
[As type] [=default value]
where Optional specifies the argument is not required (default value assigns the argument's default), ByVal and ByRef indicate the argument is to be passed by value (default in VB.NET) or by reference (default in VB6), and ParamArray specifies the argument is an Optional Variant array. ParamArray is only used with the last argument in the argument list.
|
|
[Public|Private|Friend] [Static] _
Property Set name [(arglist)][As type]
[statements]
[name = expression]
[Exit Property]
[statements]
[name = expression]
End Property
|
Declares the various parts of a Property Set procedure, which is used to obtain the value of a property.
|
(optional ) Public, Private, and Friend keywords define the procedure's scope, and (optional) Static states that the procedure's local variables are to be preserved between procedure calls. name specifies the property to be retrieved and is assigned a value (name =expression) to be returned as the property's value. The property's data type is specified using As type. (optional) Exit Property is used to immediately exit the Property Set procedure. The optional (arglist) defines the arguments that will be passed to the procedure. Those arguments should use the following syntax:
[Optional] [ByVal|ByRef] _ [ParamArray] varname[()] _
[As type] [=default value]
where Optional specifies the argument is not required (default value assigns the argument's default), ByVal and ByRef indicate the argument is to be passed by value (default in VB.NET) or by reference (default in VB6), and ParamArray specifies the argument is an Optional Variant array . ParamArray is only used with the last argument in the argument list.
|
|
Public [WithEvents] _
varname[subscripts] _
[As[New]type] [,[WithEvents] _
varname[subscripts] [As[New]type]]...
|
Declares one or more Public variables. The varname argument specifies the name of the variable being declared, and subscripts are the dimensions for an array variable.
|
(optional) As [New] type is used to specify the variable's data type, withNew enabling implicit creation of an object. (optional ) WithEvents specifies the variable declared is an object variable used to respond to events triggered by an ActiveX object. The Public statement can only be used at module level, and variables declared with it can be used outside their own module.
|
|
[Public|Private|Friend] [Static]Sub _ name [(arglist)]
[statements]
[Exit Sub]
[statements]
End Sub
|
Declares the various parts of a Sub procedure.
|
(optional) Public, Private, and Friend are used to define the Sub's scope, and (optional) Static indicates that the procedure's local variables are preserved between calls to the Sub. name specifies the name of the Sub procedure. (optional) Exit Sub is used to immediately exit the Sub procedure.
The optional list (arglist) defines what arguments will be passed to the procedure. Those arguments must use the following syntax:
[Optional] [ByVal|ByRef] _ [ParamArray] varname[()] _
[As type] [=default value]
where Optional specifies the argument is not required (default value assigns the argument's default), ByVal and ByRef control whether the argument is passed by value (default in VB.NET) or by reference (default in VB6), and ParamArray specifies the argument is an Optional array of Variant elements. ParamArray is only used with the last item in an argument list.
|
|
[Private|Public] Type varname _
elementname(subscripts) As type] _
[elementname(subscripts) As type] ...
End Type
|
Defines a user-defined type (UDT) structure that contains one or more elements (elementname).
|
(optional) Public and Private specify the UDT's scope, and varname is the UDT's name. Elements can be arrays (by specifying subscripts), and their data type must be defined using the As type clause. The Type statement can only be used at module level.
|