GetObject Function


GetObject Function

Class

Microsoft.VisualBasic.Interaction

Syntax

     Dim result As Object = GetObject([pathname][, class]) 


pathname (optional; String)

The full path and name of the COM or ActiveX object.


class (optional; String)

The class's programmatic identifier (ProgID) of the object to obtain. The ProgID is defined in the system registry and usually takes the form library.class or application.class.

Description

The GetObject function obtains an ActiveX or COM object from an already-running instance of that server. Once created, that object's members can be accessed and used.

Usage at a Glance

  • Although both pathname and class are optional, at least one parameter must be supplied.

  • In situations where you cannot create a project-level reference to an ActiveX object, you can use the GetObject function to assign an object reference from an external ActiveX object to an object variable.

  • GetObject is used when there is already a current instance of the ActiveX object; to create the first instance, use the CreateObject function.

  • If you specify pathname as a zero-length string, GetObject will return a new instance of the objectunless the object is registered as single instance, in which case, the current instance will be returned.

  • An error is generated if pathname is not specified and no current instance of the object can be found.

  • When using a variable of type System.Object to receive the result of the GetObject function, the new object will be late bound. Late binding is inherently lest robust in terms of performance than is early binding.

  • If an object is registered as a single-instance object (an out-of-process ActiveX EXE), only one instance of the object can be created at a time. Each time you call GetObject to create this object, you will obtain a reference to the same instance of the object.

  • You cannot use GetObject to obtain a reference to a class created with Visual Basic 6 or earlier.

See Also

CreateObject Function




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net