DOCUMENT:Q161052 18-MAR-1997 [vbwin] TITLE :HOWTO: Create a Default Value for Custom Controls and Classes PRODUCT :Microsoft Visual Basic for Windows PROD/VER:5.00 OPER/SYS:WINDOWS KEYWORDS:kbusage vb5all vb5howto VBKBCtrl kbhowto ====================================================================== ------------------------------------------------------------------------ The information in this article applies to: - Enterprise Edition of Microsoft Visual Basic for Windows, version 5.0 ------------------------------------------------------------------------ SUMMARY ======= Microsoft Visual Basic 5.0 allows you to create custom controls and Classes that have a default property. This behavior is similar to the intrinsic TextBox control. The TextBox control has a default value that corresponds to the string value of its Text property. This allows the following code to behave identically: MsgBox Text1.Text -and- MsgBox Text1 Both will display a dialog box containing the Text shown within the TextBox. MORE INFORMATION ================ To set an existing property as the default value for a custom control or Class, do the following: 1. Load your custom control project into Microsoft Visual Basic 5.0. 2. In the Project window, right-click your custom control or Class. Click View Code. 3. On the Tools menu, click Procedure Attributes. 4. In the Name field, select the property you wish to set as the default. 5. Click Advanced. 6. In the Procedure ID field, select Default. Click OK. The selected property is now automatically returned when you reference an instance of your control: Msgbox UserControl1.MyProperty -and- Msgbox UserControl1 are equivalent statements. REFERENCES ========== Microsoft Visual Basic version 5.0 Books Online Component Tools Guide. "General Principles of Component Design" ====================================================================== Keywords : kbusage vb5all vb5howto VBKBCtrl kbhowto Version : 5.00 Platform : WINDOWS Issue type : kbhowto ============================================================================= 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. Copyright Microsoft Corporation 1997.