Option Strict and Late Binding

  • Thread starter Thread starter Felicity
  • Start date Start date
F

Felicity

Hello,

I have the following code.

Private Sub ABC_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnA.Click, btnB.Click,
btnC.Click

if sender.name = "btnA" then
Do something etc, etc
else
Do something else etc, etc
end if

End Sub

This code works fine until I turn Option Strict On. Then
I get a blue line under the words "sender.name" with the
following message "Option Strict On disallows late
binding". I am unsure how to get access to the properties
of the button clicked in this situation using "sender".

Can anyone point me in the write direction?

Thanks

Felicity
 
-----Original Message-----


If DirectCast(sender, Control).Name = "btnA" Then

or better

If sender Is btnA Then



Mattias

Thank you so much !!!

Felicity
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top