PRB: VB5 .OCX Property Missing from VB4 Properties Window

Last reviewed: June 9, 1997
Article ID: Q169772
The information in this article applies to:
  • Microsoft Visual Basic Control Creation, Professional, and Enterprise Editions for Windows, version 5.0
  • Microsoft Visual Basic Standard, Professional, and Enterprise Editions, 32-bit only, for Windows, version 4.0

SYMPTOMS

A public property of an ActiveX Control (.OCX) created in Visual Basic 5.0 does not appear in the Properties Window when the control is used in Visual Basic 4.0's design environment.

CAUSE

By default, a Public Property Let procedure passes its arguments by reference and not by value. When these arguments are passed by reference from an ActiveX Control (.OCX), the property will not be visible in the Visual Basic 4.0 Properties Window.

RESOLUTION

To resolve this problem, be sure that all arguments passed by a Public Property Let procedure are passed by value. For example, if you have the following property procedure definition:

   Public Property Let MyProperty(newValue As Boolean)

it needs to be changed to:

   Public Property Let MyProperty(ByVal newValue As Boolean)

to work correctly.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. In Visual Basic 5.0, start a new ActiveX Control project. UserControl1 is created by default. Change the Project name (not the file name) to "UserCtl1."

  2. Add the following code to the General Declarations section of UserControl1:

          'A public variable is always visible in the Properties Window.
          Public VisibleProperty as Boolean
    

          Public Property Get HiddenProperyA() as Boolean
          End Property
    

          Public Property Let HiddenPropertyA(newValue as Boolean)
    
            'By default the argument is passed by reference.
            'This property will not be displayed in Properties Window.
          End Property
    
          Public Property Get HiddenPropertyB() as Boolean
          End Property
    
          Public Property Let HiddenPropertyB(ByVal newValue as Boolean)
             'This argument is passed by value.
             'This property will be displayed in Properties Window.
          End Property
    
    

  3. Save the project and select 'Make UserCtl1.ocx...' from the File menu. Close Visual Basic 5.0.

  4. If Visual Basic 4.0 is installed on the same system as Visual Basic 5.0, skip to step 5. If Visual Basic 4.0 is installed on a different system, you will need to create a set of distribution disks or a net setup to install your ActiveX Control on the Visual Basic 4.0 computer. Once the ActiveX Control is successfully installed and registered on the Visual Basic 4.0 system, you can continue.

  5. Create a new project in Visual Basic 4.0. Form1 is created by default.

  6. Select Custom Controls from the Tools menu and select your ActiveX Control. It should be listed as 'UserCtl1.'

  7. Add your ActiveX Control to Form1 and view the Properties Window. You should be able to see and set the values of "VisibleProperty" and "HiddenPropertyB" in the Properties Window. You cannot see the "HiddenPropertyA" property in the Properties Window.

    In the Object Browser you will be able to see all of the control's properties. All of these properties can be set in code at runtime.


Keywords : vb432 vb4win vb5all VBKBAX VBKBComp VBKBCtrl VBKBEnv kbprb
Version : 4.0 5.0
Platform : WINDOWS
Issue type : kbprb


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 9, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.