sender Is (control) with Option Strict On

 
Select Case True
    Case sender Is PrintPreviewToolStripMenuItem, sender Is PrintPreviewToolStripButton
 
From
You can use Select Case as in the following:

Select Case True
   Case sender Is TextBox1
      Label1.Text = TextBox1.Text
  
Case sender Is TextBox2
      Label1.Text = TextBox2.Text
End Select

However, this translates into IL (and decompiled using Reflector) as:

 Dim flag1 As Boolean = True
      If (flag1 = (sender Is Me.TextBox1)) Then
            Me.Label1.Text = Me.TextBox1.Text
      Else
            If (flag1 = (sender Is Me.TextBox2)) Then
                  Me.Label1.Text = Me.TextBox2.Text
            End If
      End If

I don’t know if this helps.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: