Creating Classes & ActiveX Controls

Mapping your controls' properties onto other contr

If you want to have a property for your control, that you want to map directly to another controls property (ie if you have a text box in your control, and when the user changes your controls Text property, you want it to automattically change the Textbox's text property), then you can do the following:

'// the back color property. This is called when the client requests the value of BackColor
Public Property Get Text() As String
    BackColor = txtMain.Text  '// return the textbox.text property
End Property

'// this is called when the client requests to change the value of BackColor.
Public Property Let Text(ByVal Text As String)
    '// if the property is read only (ie the client cannot change its value), you do not need this procedure.

    '// before you assign the new value, you could check to see if it is empty etc:
    '// If New_Text = Empty Then Exit Property

    txtMain.Text = New_Text '// set the textbox.text property to the new value
    PropertyChanged "Text"  '// property has changed
End Property

You might also like...

Comments

About the author

James Crowley

James Crowley United Kingdom

James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audien...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Programs must be written for people to read, and only incidentally for machines to execute.”