ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How I can determine a base class of a procedure's incoming parameter? (https://www.excelbanter.com/excel-programming/282259-how-i-can-determine-base-class-procedures-incoming-parameter.html)

Dmitry V. Petkun

How I can determine a base class of a procedure's incoming parameter?
 
1878026431
In VBA (Excel) I'm written procedure with an incoming parameter of type
Object. I need to determine which base class (not type) has this parameter.
How I can do it?

Public Sub FillControl(TargetControl As Object, SomeRS As ADODB.Recordset)
If [TargetControl is ComboBox] Then
TargetControl.AddItem "Item1"
...
ElseIf [TargetControl is Label] Then
TargetControl.Text = "Some text"
...
End If
End Sub

Thanks!

Dmitry V. Petkun



Tushar Mehta

How I can determine a base class of a procedure's incoming parameter?
 
Check if TypeOf gives you what you want as in:

If TypeOf TargetControl is ComboBox then...

Strangely enough, it is documented only as part of the help on the
'If...Then...Else Statement'.

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
1878026431
In VBA (Excel) I'm written procedure with an incoming parameter of type
Object. I need to determine which base class (not type) has this parameter.
How I can do it?

Public Sub FillControl(TargetControl As Object, SomeRS As ADODB.Recordset)
If [TargetControl is ComboBox] Then
TargetControl.AddItem "Item1"
...
ElseIf [TargetControl is Label] Then
TargetControl.Text = "Some text"
...
End If
End Sub

Thanks!

Dmitry V. Petkun





All times are GMT +1. The time now is 05:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com