Limits of VB 3.0 & Disptest as Automation Controllers

Article translations Article translations
Article ID: 122287 - View products that this article applies to.
This article was previously published under Q122287
Expand all | Collapse all

On This Page

SUMMARY

Visual Basic version 3.0 for Windows and Disptest (the automation controller that shipped with OLE version 2.0) have the following limitations as automation controllers in addition to those described on pages 67-69 of the OLE 2 Programmer's Reference, Volume 2:

  • Parameters cannot be passed by reference to Automation properties or methods.
  • Array elements cannot be accessed.
  • When an exception is raised by an automation object, the value of the wCode field of the EXCEPINFO structure is not used. Instead the value 440 is displayed.
NOTE: All of these limitations have been removed in Visual Basic version 4.0.

MORE INFORMATION

Parameters Cannot Be Passed by Reference

Visual Basic version 3.0 for Windows and Disptest cannot pass parameters by reference to automation properties and methods.

This is a limitation of Visual Basic version 3.0 and Disptest, not of OLE Automation. OLE Automation allows building controllers that pass parameters by reference.

Here are three workarounds:

  • Use return values of properties and methods to return a value instead of using byref parameters for this purpose. This approach cannot be used when a property or method returns multiple values. -or-

  • Use third party controllers (see the list below) while you wait for a future version of Visual Basic, or use Visual Basic for Applications, which ships with Microsoft Excel version 5.0. Microsoft Visual Basic for Applications cannot be redistributed by or incorporated into products that are not manufactured by Microsoft. However, if user of your application has Microsoft Excel version 5.0 installed, you can use its Visual Basic for Applications as a controller of any Automation server.

    Here are two known third-party controllers:

    NOTE: The products included here are manufactured by vendors independent of Microsoft; we make no warranty, implied or otherwise, regarding these products' performance or reliability.

    Softbridge Basic Language
    Mystic River Software, Inc. 125 CambridgePark Drive, Cambridge MA 02140
    Tel:1-800-298-3500, 617-497-1585
    Fax:617-864-7747

    Summit BasicScript
    Summit Software Company, 2844 Sweet Road, Jamesville, NY 13078
    Tel: 315-677-9000
    Fax: 315-677-3224
    Internet: info@summsoft.com -or-

  • Write a DLL that has exported functions that correspond to Automation methods and properties exposed by the automation server. Visual Basic version 3.0 can call these exported DLL functions, which in turn can call the corresponding automation properties or methods in the automation server. This approach works because Visual Basic version 3.0 can pass parameters by reference to DLL functions.

    The DLL functions can pass parameters by reference to the properties and methods of the automation method or property because OLE supports passing parameters by reference. This approach may not be suitable for some automation servers that implement nested objects.

Array Elements Cannot Be Accessed

Array elements cannot be accessed in Visual Basic version 3.0 or Disptest. As a result, code similar to the following code cannot be executed in Visual Basic version 3.0 or in Disptest if selection returns a safearray. This is because safearray elements cannot be accessed in Visual Basic version 3.0 or in Disptest.
   Value = ObjVar.Selection(I)
   ObjVar.Selection(I) = Value
				
Workarounds include using indexed properties, third-party controllers, Visual Basic for Applications in Microsoft Excel version 5.0, or waiting for a future release of Visual Basic.

Indexed properties are properties that take parameters. For example, in the example code, Selection could be made a property that takes an index parameter. Here is a description in the .ODL file of an indexed parameter called Value whose property type is VARIANT:
   [propget] VARIANT Value(long index);
   [propput] void Value(long index, VARIANT NewValue);
				
In a dispinterface, an indexed property should be used under the 'methods' keyword. A Microsoft Foundations Classes (MFC) implementation can use the DISP_PROPERTY_PARAM macro in the dispatch map to implement an indexed property.

The disadvantage of implementing array element access using indexed properties is the performance penalty caused by each indexed property access requiring the overhead of an RPC/LRPC call (for LocalServer Automation objects).

Value of EXCEPINFO.wCode Not Displayed on Exceptions

When an automation object raises an exception by returning DISP_E_EXCEPTION from IDispatch::Invoke and by filling the pexcepinfo parameter of this method, Visual Basic version 3.0 and Disptest will ignore the value returned in the wCode field of the EXCEPINFO structure, instead returning the value 440. Note that either the wCode or scode field of EXCEPINFO should be set to 0 -- both cannot be used.

Workarounds include using third-party controllers, Visual Basic for Applications in Microsoft Excel version 5.0, or waiting for a future release of Visual Basic.

Properties

Article ID: 122287 - Last Review: October 30, 2003 - Revision: 2.0
APPLIES TO
  • Microsoft Visual Basic 3.0 Professional Edition
  • Microsoft OLE 2.02
Keywords: 
kbautomation kb3rdparty KB122287

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com