Implementing Control's
Properties
Every control has few properties as default: Name,
Left, Index, Tag, and more.
Our control will inherit those properties as
default.
But we want that
our control will have some properties that
he doesn't get as default, like
Text - the text of the message box
that will pop
when the user press the button.
Implementing Text Property
We have 2 occasions: when reading the Text
property and
when changing the Text property.
The
reading occasion occur when we want to
read the porperty that the user set.
For example if the user set the control Text property to "hello",
the
reading result will return "hello".
Lets implement first the reading
occasion.
Enter the
following code to your form:
Dim TextVariable As String
The TextVariable will be the variable that holds for us the value of the Text
property, therefore the String that will be inserted into the message
box.
Enter the following code to your form:
Private Sub UserControl_ReadProperties(PropBag
As PropertyBag)
TextVariable =
PropBag.ReadProperty("Text", "There is no message")
End
Sub
The function above says: read the
control's "Text" property.
If the reading yield nothing, set as default the
Text property
to be "There is
no message".
We called
to read the Text property,
now we have to implement
the reading method:
Public Property Get Text() As
String
Text = TextVariable
End Property