Sub RandomObject As Object
Select Rnd(0, 2)
Case 0
Return CreateFruit(TxtName.Text, "", "")
Case Else
Dim someone As Person
someone.Initialize
someone.FirstName = TxtName.Text
Return someone
End Select
End Sub
Sub ShowTheObject (obj As Object)
Select GetType(obj)
Case "b4a.example.person"
MsgboxAsync("The person first name is " & obj.As(Person).FirstName, "Person")
Case "b4a.example.main$_fruit"
MsgboxAsync("The fruit name is " & obj.As(Fruit).Name, "Fruit")
End Select
End Sub