UserControl Default Property
I have this code for a UserControl called fnd. What I want is to make the ContactNumber property the default property. For example, with a textbox called txt you can do vMyText = txt and it returns the default Text property. How do I make ContactNumber the default?
VB Code:
Option Explicit
Private mvContactNumber
Public Property Get ContactNumber() As Long
ContactNumber = mvContactNumber
End Property
Public Property Let ContactNumber(ByVal pContactNumber As Long)
If pContactNumber > 0 Then
UserControl.PropertyChanged ContactNumber
txt.Text = pContactNumber
End If
End Property
Private Sub txt_Change()
With txt
If .Text = Val(.Text) Then
mvContactNumber = .Text
Else
mvContactNumber = 0
End If
End Sub
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
ContactNumber = PropBag.ReadProperty("ContactNumber", 0)
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "ContactNumber", ContactNumber, 0
End Sub
Re: UserControl Default Property
Click somewhere in your property get/set procedures, and go to Tools->Procedure Attributes. Click Advanced, somewhere in there is a box called Procedure ID, in there select (Default).