Ho letto che a runtime non si può avere il tipo dell'oggetto:
http://www.thescripts.com/forum/thread382022.html
Per l'ennesima volta devo cercare un' alternativa (ma quando faranno un linguaggio che fa quello che voglio io???) per cui ho utilizzato questo sistema meno elegante ma funzionale:
Codice PHP:
Dim myText As String
If TypeOf sender Is Button Then
mytext = CType(sender, Control).Text
ElseIf TypeOf sender Is ToolStripMenuItem Then
myText = CType(sender, ToolStripMenuItem).Text
Else
HandleMsg("HandleListbox: Controllo non gestito.")
Exit Sub
End If
Select Case mytext
Case "Apply"
bla bla bla
Case "Cancel"
bla bla bla
End Select