Using sender
A curious thing, is there a reason that you can't declare sender as a specific type? For instance, if you had a number of textboxes and you wanted each one to select all it's text when you click on it could you use :
Public Sub TextBox_Click(ByVal sender As TextBox, ByVal e As System.EventArgs)
sender.SelectAll()
End Sub
and add it as the Click Event handler to each textbox.
It seems kind of obvious to me, and it does work. But I'm wondering if there is something deep inside visual studio that'll get screwed up.
Related Article: vb.net vs vb6
is a VB.NET discussion thread by Zick Technology that has 5 replies and was last updated 5 months ago.
tinstaafl
Nearly a Posting Virtuoso
1,470 posts since Jun 2010
Reputation Points: 429
Solved Threads: 262
Skill Endorsements: 14
To make that work you need to have Option Strict Off which is something I personally do not care for, but to each their own.
You are forcing a narrowing implicit conversion on the method signature (delegate). Based on Variance in Delegates (C# and Visual Basic) I believe you are safe.
TnTinMN
Practically a Master Poster
640 posts since Jun 2012
Reputation Points: 418
Solved Threads: 149
Skill Endorsements: 13
tinstaafl
Nearly a Posting Virtuoso
1,470 posts since Jun 2010
Reputation Points: 429
Solved Threads: 262
Skill Endorsements: 14
Question Answered as of 4 Months Ago by
TnTinMN And it's not that much extra typing to do
DirectCast(sender,TextBox).SelectAll()
Reverend Jim
Illigitimae non carborundum
3,740 posts since Aug 2010
Reputation Points: 585
Solved Threads: 469
Skill Endorsements: 33