Microsoft KB Archive/169772
Article ID: 169772
Article Last Modified on 6/24/2004
- Microsoft Visual Basic 5.0 Control Creation Edition
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 6.0 Professional Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
- Microsoft Visual Basic 6.0 Enterprise Edition
- Microsoft Visual Basic 4.0 Standard Edition
- Microsoft Visual Basic 4.0 Professional Edition
- Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
This article was previously published under Q169772
A public property of an ActiveX Control (.OCX) created in Visual Basic 5.0 or Visual Basic 6.0 does not appear in the Properties Window when the control is used in Visual Basic 4.0's design environment.
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.
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.
This behavior is by design.
Steps to Reproduce Behavior
- In Visual Basic 5.0 or 6.0, start a new ActiveX Control project. UserControl1 is created by default. Change the Project name (not the file name) to "UserCtl1."
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
- Save the project and select 'Make UserCtl1.ocx...' from the File menu. Close Visual Basic.
- If Visual Basic 4.0 is installed on the same system as Visual Basic 5.0 or 6.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.
- Create a new project in Visual Basic 4.0. Form1 is created by default.
- Select Custom Controls from the Tools menu and select your ActiveX Control. It should be listed as 'UserCtl1.'
- 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: kb32bitonly kbprb kbctrl KB169772