Creating Classes & ActiveX Controls

Methods

Methods are basically a controls public procedures and functions. If you want to make a procedure or function a method for your control (that the client can call), simply declare it as public. Private procedures and functions are not available to the client (and a good thing too!).

'// Public Refresh method
Public Sub Refresh()
    UserControl.Refresh
    txtMain.Refresh
End Sub

'// Private update method
Private Function Update(txtText As TextBox)
    '// update text box
End Function

If you want to simply want to have a method that calls the method of another control on your user control (get that?), then you make your public function or sub have the same return type and parameters:

'// public Find method
Public Function Find(bstrString As String, Optional vStart, Optional vEnd, Optional vOptions) As Long
    '// call the RTB's find method, and return result
    Find = rtfMain.Find (bstrString, vStart, vEnd, vOptions)
End Function

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.

“Better train people and risk they leave – than do nothing and risk they stay.” - Anonymous