AddHandler Statement |
|
AddHandler NameOfEventSender, AddressOf NameOfEventHandler |
|
NameOfEventSender required; String literal
The name of a class or object instance and its event, such as Button1.Click
NameOfEventHandler required; String literal
The name of a subroutine that is to serve as the event handler for NameOfEventSender
Binds an event handler to a built-in or custom event. This makes it possible to bind several event handlers to a single event.
NameOfEventSender takes the form class.event or object.event
You can stop handling events defined by the AddHandler statement by calling the RemoveHandler statement
AddressOf Operator |
|
AddressOf procedurename |
|
procedurename required
The name of a procedure that is referenced by the procedure delegate
The AddressOf operator returns a procedure delegate instance that references a specific procedure. It is used in the following situations:
If a parameter to a procedure (a VB procedure or a Win32 API function) requires a function pointer (the address of a function), then we can pass the expression:
AddressOf functionname
where functionname is the name of the function. This function is called a callback function.
AddressOf is also used to create delegate objects, as in:
delg = New ADelegate(AddressOf obj.AMethod)
AddressOf is used to bind event handlers to events through the AddHandler statement:
AddHandler Form1.Click, AddressOf Me.Form1Click
Class...End Class Statement |
|
|
|
See Class...End Class Statement entry under Section 1.16.
COMClass Attribute | Microsoft.VisualBasic.COMClassAttribute |
|
|
Adds metadata that allows a .NET class to be exposed as a COM object. You can supply the attribute with a class identifier, an interface identifier, and an event identifier. All are globally unique identifiers (GUIDs) that can be generated either by using the guidgen.exe utility or automatically by using the COM Class Wizard. They ensure that the COM component retains the same GUIDs when it is recompiled.
New([[[classID], interfaceID], eventID])
classID String
The class identifier (CLSID) that will uniquely identify the COM class
interfaceID String
The interface identifier (IID) that uniquely identifies the class' default COM interface
eventID String
The event identifier that uniquely identifies an event
ClassID String
Read-only. Provides the CLSID that uniquely identifies a COM class. Its value is set by the classID parameter of the class constructor.
EventID String
Read-only. Provides the GUID that uniquely identifies an event. Its value is set by the eventID parameter of the class constructor.
InterfaceID String
Read-only. Provides the IID that uniquely identifies a COM interface. Its value is set by the interfaceID parameter of the class constructor.
InterfaceShadows Boolean
Indicates whether the COM interface name is the same as the name of another member of the class or the base class. Its default value is False.
CreateObject Function | Microsoft.VisualBasic.Interaction |
objectvariable = CreateObject(progid [, servername]) |
|
objectvariable required; Object
A variable to hold the reference to the instantiated object
progid required; String
The programmatic identifier (or ProgID) of the class of the object to create
servername optional; String
The name of the server on which the object resides
No
A reference to a COM or ActiveX object
Creates an instance of an OLE Automation (ActiveX) object.
Prior to calling the methods, functions, or properties of a COM or ActiveX object, you are required to create an instance of that object. Once an object is created, reference it in code using the object variable you defined.
Declare Statement |
|
|
|
See Declare Statement entry under Section 1.16.
Event Statement |
|
[accessmodifier] [Shadows] Event eventName [(arglist)] [Implements interfacename.interfaceeventname] |
|
accessmodifier optional; Keyword
Can be one of Public, Private, Protected, Friend, and ProtectedFriend.
Shadows optional; Keyword
Indicates that the event shadows any programming elements of the same name in a base class.
eventName required; String literal
The name of the event.
arglist
is optional and has the following syntax:
[ByVal | ByRef] varname[( )] [As type]
ByVal optional; Keyword
The argument is passed by value; that is, a local copy of the variable is assigned the value of the argument. ByVal is the default method of passing variables.
ByRef optional; Keyword
The argument is passed by reference; that is, the local variable is simply a reference to the argument being passed. All changes made to the local variable are reflected in the calling argument.
varname required; String literal
The name of the local variable containing either the reference or value of the argument.
type optional; Keyword
The data type of the argument. It can be Byte, Boolean, Char, Short, Integer, Long, Single, Double, Decimal, Date, String, Object, or any user-defined structure, object type, or data type defined in the BCL.
Implementsinterfacename.interfaceeventname optional
Indicates that the event implements a particular event named interfaceeventname in the interface named interfacename.
Defines a custom event that the object can raise at any time using the RaiseEvent statement.
Environ Function |
|
|
|
See Environ Function entry under Section 1.23.
Get Statement |
|
Get( ) [ statements ] End Get |
|
statements optional
Program code to be executed when the Property Get procedure is called
Defines a Property Get procedure that returns a property value to the caller.
GetObject Function | Microsoft. VisualBasic.Interaction |
GetObject([pathname] [, class]) |
|
pathname optional; String
The full path and name of the file containing the COM (or ActiveX) object.
class optional; String
The class of the object. The class argument has these parts:
Appname required; String
The name of the application.
Objecttype required; String
The class of object to create, delimited from Appname by using a period ( . ). For example, Appname.Objecttype.
A reference to an ActiveX object
Accesses an ActiveX server held within a specified file.
Handles Keyword |
|
Handles name.event |
|
name required; String literal
The name of the class or object whose event the subroutine is handling
event required; String literal
The name of the event that the subroutine is handling
Defines a procedure as the event handler for a particular event.
Implements Keyword |
|
Implements interfacename.interfacemember [, ...] |
|
interfacename required; String literal
The name of the interface being implemented by a class
interfacemember required; String literal
The name of the interface property, function, procedure, or event that is being implemented by a class
Indicates that a class member provides the implementation of a member defined in an interface.
Implements Statement |
|
Implements InterfaceName [,InterfaceName][,...] |
|
InterfaceName required; String literal
The name of the interface that a class implements
The Implements statement specifies that you will implement an interface within the class in which the Implements statement appears.
Imports Statement |
|
Imports [aliasname = ] namespace [.element] |
|
aliasname optional; String literal
The name by which the namespace will be referenced in the module
namespace required; String literal
The name of the namespace being imported
element optional
The name of an element in the namespace
Imports namespaces or parts of namespaces, making their members available to the current module.
Inherits Statement |
|
Inherits classname |
|
classname required; String literal
The name of the inherited (base) class
Specifies the name of the class that is being inherited, that is, the base class. The statement can appear immediately after the Class statement or the Interface statement.
Interface Statement |
|
[ accessmodifier ] [Shadows] Interface name ...statements End Interface |
|
accessmodifier optional; Keyword
One of the following keywords, which determines the visibility of the interface:
Public optional; Keyword
Indicates that the interface is publicly accessible anywhere both inside and outside of the project.
Private optional; Keyword
Indicates that the interface is accessible to any nested types, as well as to the type (if any) in which it is defined.
Protected optional; Keyword
Indicates that the interface is accessible only to derived classes; a protected interface can only be declared inside of a class.
Friend optional; Keyword
Indicates that the interface is accessible only within the project that contains the interface definition.
Protected Friend optional; Keyword
Indicates that the interface is declared inside of a class and that it is accessible throughout the project that contains the interface definition, as well as to derived classes.
Shadows optional; Keyword
Indicates that the interface shadows an identically named element in a base class.
name required; String literal
The name of the interface.
statements required
Code that defines the interface members that derived classes must implement.
Defines a virtual base class along with its public members. The interface can then be implemented by derived classes using the Implements statement.
Is Operator |
|
object1 Is object2 object1 required; Object or any reference type object2 required; Object or any reference type |
|
Boolean
Compares two object variables or reference variables to determine whether they reference the same object.
Len Function | Microsoft.VisualBasic.Strings |
Len(expression) |
|
expression required; any
Any valid variable name or expression
Integer
Counts the number of characters within a string or the size of a given variable.
Me Operator |
|
Me |
|
Represents a reference to the current class from within the class.
MyBase Keyword |
|
MyBase |
|
Provides a reference to the base class from within a derived class. If you want to call a member of the base class from within a derived class, you can use the syntax:
MyBase.MemberName
where MemberName is the name of the member. This will resolve any ambiguity if the derived class also has a member of the same name.
MyClass Keyword |
|
MyClass |
|
Provides a reference to the class in which the keyword is used.
Namespace Statement |
|
Namespace name component types End Namespace |
|
name required; String literal
The name of the namespace
component types required
The elements that are being declared as part of the namespace, including Enums, Structures, Interfaces, Classes, Delegates, Modules, and other namespaces
Declares a namespace and specifies the items in it.
Property Statement |
|
|
|
See Property Statement entry under Section 1.16.
RaiseEvent Statement |
|
RaiseEvent eventName([arglist]) |
|
eventName required; String literal
The name of the event
arglist optional; any (defined by the Event statement)
A comma-delimited list of arguments
Generates a predefined, custom event within any procedure of an object module
RemoveHandler Statement |
|
RemoveHandler NameOfEventSender, AddressOf NameOfEventHandler |
|
NameOfEventSender required; String literal
The name of a class or object instance and its event, such as Button1.Click
NameOfEventHandler required; String literal
The name of a subroutine to remove as event handler for NameOfEventSender
Removes a previous binding of an event handler to a built-in or custom event.
Shadows Keyword |
|
Shadows |
|
When a member of a derived class has the same name as a member of the same type in the base class, and the keywords Overridable and Overrides are used appropriately, then the derived class member overrides the base class member. That is, any reference to the member using a derived class object refers to the implementation in the derived class.
Shadowing works in a similar way but allows any member type to "override" any other member type. Thus, for example, a method can "override" a property.
SyncLock Statement |
|
SyncLock expression ...[ code ] End SyncLock |
|
expression required; any reference type (class, module, interface, array, or delegate)
An expression yielding a single result that can be used to determine the accessibility of code
code optional
The code statements to which access is synchronized and that will be executed sequentially
Prevents multiple threads of execution in the same process from accessing shared data or resources at the same time
WithEvents Keyword |
|
Dim|Private|Public WithEvents objVarName As objectType |
|
objVarName required; String
The name of any object variable that refers to an object that exposes events
objectType required; any object type other than the generic Object
The ProgID of a referenced object
Informs VB that the object being referenced exposes events for which you intend to provide event handlers.