You have 2 options:
Method A) Expose the control itself as a public property of your UserControl, like this:
Public Property Get TextBox as TextBox
'This will return a reference to
'a textbox on the UserControl.
Set TextBox = txtMyTextBox
'To call this from another form
'or control use this syntax:
'MyControl.TextBox
End Property
However, it is strongly advised that you do NOT expose constituent controls directly from within an ActiveX componenet. Instead you should try Method B.
Method B) Expose the *properties* of your consituent controls as properties of your UserControl, like this:
Public Property Get Text as String
'Returns the text property of the
'textbox on the UserControl.
Text = txtMyTextBox.Text
End Property
Keep in mind that not all properties of every consituent control need to be exposed as UserControl properties. You should only expose the properties which the user of the control would need to interact with directly.
For instance, with a textbox, you would most likely want to expose the Text property, but not the Height, Width, Top or Left properties. Resizing and moving the control around should be handled by your UserControl. If you do want to provide a means for the user to move/resize the textbox, you might want to instead consider a function similar to the Move method on VB forms, like this:
Public Sub MoveTextBox(Left As Single, Top As Single, Width As Single, Height As Single)
'Alter textbox's size and position.
With txtMyTextBox
'Assign textbox's left property.
.Left = Left
'Assign textbox's top property.
.Top = Top
'Assign textbox's width property, if it is valid.
If Width > 0 Then .Width = Width
'Assign textbox's height property, if it is valid.
If Height > 0 Then .Height = Height
End With
End Sub
Main Topics
Browse All Topics





by: wsh2Posted on 2000-06-21 at 08:17:03ID: 3027051
Use the control wizard to map the properties.