Hi,
I want to implement a sub that can receive many types of classes as parameter (e.g. CustomLabel, CustomTextField etc.). Today I'm doing the following:
I would like to implement something like:
"element As CustomComponent" instead of "element as Object".
How can this be accomplished?
And... What is the best way to handle the component type inside the sub? (is "If element Is CustomLabel Then" a good solution ?)
Thank you very much.
I want to implement a sub that can receive many types of classes as parameter (e.g. CustomLabel, CustomTextField etc.). Today I'm doing the following:
B4X:
Public Sub AddElement(element As Object)
If element Is CustomLabel Then
...
else if element Is CustomTextField then
...
...
End Sub
I would like to implement something like:
B4X:
Public Sub AddElement(element As CustomComponent)
If element Is CustomLabel Then
...
else if element Is CustomTextField then
...
...
End Sub
"element As CustomComponent" instead of "element as Object".
How can this be accomplished?
And... What is the best way to handle the component type inside the sub? (is "If element Is CustomLabel Then" a good solution ?)
Thank you very much.