Make Your First ActiveX Control

Lesson 1
Tutorials - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14

Implementing The Writing Method
The write occasion occur when the user change the Text property.
In that case, we need to update the variable that
holds for us the propery value (TextVariable).

Enter the Following code to your form:

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    Call PropBag.WriteProperty("Text", TextVariable, "There is no message")
End Sub


The function above says:
Write the new property value to TextVariable,
and update the Text Property.
If the writing to the TextVariable return nothing,
Set the Text property value to be "There is no message".

Now we have to implement the writing method,
where the new property value will be entered into the TextVariable.
Enter the following code to your form:

Public Property Let Text(ByVal New_Text As String)
    TextVariable = New_Text
    PropertyChanged "Text"
End Property

The new Text property value is passed with the New_Text parameter.
Of course this parameter have to be String, because the Text property holds String.
We set the TextVariable variable to hold the new Text property value.
Then we announce that the "Text" property has been changed.

Back  Forward