Library tutorials & articles

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

Comments

  1. 18 Jan 2005 at 10:56

    Is it possible for a dll to use an ocx and its methods? How do I declare it?

  2. 04 Nov 2004 at 05:57

    thanks!!! a great help for developers.










    --all glory to my great provider...--

  3. 13 Apr 2003 at 16:12

    Of all the books and tutorials I've read on classes & activeX,this should be the best.Thanx to the author.

  4. 28 Feb 2002 at 16:39

    I am fairly new at coding in VB and love diving in.  I am working on a project on reading binary files, parsing bit data information and creating a display from some function of bits.  The first couple of words will tell me how to set up a window and other parameters.  Since my first run at creating this program, I have since discovered the use of classes as separate modules.  I'm trying to create a couple of classes, one for setting of the parameters and the other for program settings.  Using the Property of Let & Get has worked great and makes the management of what I am doing easier.  But I have a couple of questions regarding of how to try to pass arrays like I would the other values.  
     For example, recalling a list of last opened file names and making them available to other modules, I had wanted to try to put it in a class like the other properties, but when I don't know if and how many how do I do that?  
     

  5. 01 Jan 1999 at 00:00

    This thread is for discussions of Creating Classes & ActiveX Controls.

Leave a comment

Sign in or Join us (it's free).