Controls As Arguments
In the previous section, you have seen how variables
can be passed between procedures. Variables are not
the only kind of data you can pass between procedures.
You can pass controls also. The control can be any
one of the following types:
CheckBox Image PictureBox OptionButton
Rectangle ComboBox Label OptionGroup Shape CommandButton
Line PageBreak TextBox Graph ListBox ToggleButton
A function may receive a control variable like this:
Public Function MyControls (obj As
Object)
If a function receives an argument declared as the
Object data type, you can test the kind of control
the argument holds with the help of TypeOf:
If TypeOf obj Is CommandButton Then
ElseIf TypeOf obj Is CheckBox Then
End If
|