Link to home
Start Free TrialLog in
Avatar of deming
deming

asked on

How to pass a Control to a Sub?

I have an ActiveX control that I can drag and drop onto a form. It has no way to create the object on the fly, rather it must be dragged and dropped onto the form. It is a third party object.  I need 10 instances of this control, so I have dragged 10 of them on to my form. They are called x1, x2, x3, etc.

I now have set the various properties to values such as:
x1.Color = vbRed
x1.Speed = 1
x2.Color = vbBlack
x2.Speed = 5

QUESTION:
How do I pass these objects to a function to set the properties?  I want to do something like this:

Call SetProperties( x1, vbRed, 1 )
Call SetProperties( x2, vbBlack, 5)

I tried:
Public Sub SetProperties( MyObj as Object)   but it does not allow me to access the properties.

I tried:
Public Sub SetProperties( MyObj as Control)   but it does not allow me to access the properties either.


Thank you.

ASKER CERTIFIED SOLUTION
Avatar of TeraByteMan
TeraByteMan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial