From: Chris Dunaway on
On Jun 11, 5:50 am, "Phill W." <p-.-a-.-w-a-r...@-o-p-e-n-.-a-c-.-u-k>
wrote:
> On 10/06/2010 20:36, Mr. X. wrote:
>
> > I need to check whether the current object Is a specific class,
> > For example :
> > function a(b as object)
>
> Why?
> Bear with me: It's not as silly a question as it sounds; it depends on
> what you want to /do/ with it once you've found it.
>
> (1) If you want a method that, say, enables or disables the control that
> you pass to it, but you want it to work for lots of different Types of
> Control (contrived, but a common thing to do), use overloading:
>
> Function Z( byval btn as Button, byval enabled as Boolean )
> Function Z( byval tb as TextBox, byval enabled as Boolean )
> Function Z( byval cmb as ComboBox, byval enabled as Boolean )
>

No need for overloading in this case. Just set the parameter type as
Control. The Enabled property is inherited from Control:

Private Sub Z(ByVal c As Control, ByVal enabled As Boolean)
c.Enabled = enabled
End Sub

Chris
First  |  Prev  | 
Pages: 1 2
Prev: Datagridview selected rows
Next: Inheritance and COM