By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,289 Members | 1,283 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,289 IT Pros & Developers. It's quick & easy.

error when Option Strict On

P: n/a
Hi

The following generates an error when Option Strict is On
Can anytell tell me how to get round this please.

Private Sub optWithTone_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles optWithTone.CheckedChanged

If eventSender.Checked Then

pAlarmOption = NokiaCLCalendar.CalendarAlarmType.CALENDAR_ALARM_W ITH_TONE

txtAlarmTime.Enabled = True

End If

End Sub

The control is a radio button and the error is - Option Strict On disallows late binding.

Thanks in advance


Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Starbuck" <St******@tisconi.com> schrieb;
'The following generates an error when Option Strict is On
Can anytell tell me how to get round this please.

Private Sub optWithTone_CheckedChanged(ByVal eventSender As System.Object,
ByVal >eventArgs As System.EventArgs) Handles optWithTone.CheckedChanged

If eventSender.Checked Then
\\\
If DirectCast(eventSender, RadioButton).Checked Then
...
End If
///
The control is a radio button and the error is - Option Strict On
disallows late binding.


--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2

P: n/a
Hi Starbuck,

"Late Binding" is the practice of dynamically discovering the type of an
object at runtime. It incurs a performance penalty since .NET has to do
a lot of running around for one simple statement.

Late binding also makes for less readable code, which is one of the
reasons coding with "Option Strict On" is recommended.

So before you could check the "Checked" (haha) property of the
eventSender argument, you need to cast eventSender to the type
"RadioButton" first:

----
If DirectCast(eventSender, RadioButton).Checked Then
' do the rest here...
End If
----

The inverse of late-binding is early binding. In early-binding the types
of objects are known at compile time and the compiler handles them
accordingly.

The cast above makes the code early-bound (the compiler knows the real
type of eventSender at compile-time) and helps create more readable code.

Regards,
-Adam.

Starbuck wrote:
Hi

The following generates an error when Option Strict is On
Can anytell tell me how to get round this please.
Private Sub optWithTone_CheckedChanged(ByVal eventSender As
System.Object, ByVal eventArgs As System.EventArgs) Handles
optWithTone.CheckedChanged

If eventSender.Checked Then

pAlarmOption =
NokiaCLCalendar.CalendarAlarmType.CALENDAR_ALARM_W ITH_TONE

txtAlarmTime.Enabled = True

End If

End Sub

The control is a radio button and the error is - Option Strict On
disallows late binding.

Thanks in advance



Nov 21 '05 #3

P: n/a
Thanks Guys

"Adam Goossens" <ad**********@users.sourceforge.net> wrote in message
news:eN**************@TK2MSFTNGP15.phx.gbl...
Hi Starbuck,

"Late Binding" is the practice of dynamically discovering the type of an
object at runtime. It incurs a performance penalty since .NET has to do a
lot of running around for one simple statement.

Late binding also makes for less readable code, which is one of the
reasons coding with "Option Strict On" is recommended.

So before you could check the "Checked" (haha) property of the eventSender
argument, you need to cast eventSender to the type "RadioButton" first:

----
If DirectCast(eventSender, RadioButton).Checked Then
' do the rest here...
End If
----

The inverse of late-binding is early binding. In early-binding the types
of objects are known at compile time and the compiler handles them
accordingly.

The cast above makes the code early-bound (the compiler knows the real
type of eventSender at compile-time) and helps create more readable code.

Regards,
-Adam.

Starbuck wrote:
Hi
The following generates an error when Option Strict is On
Can anytell tell me how to get round this please.
Private Sub optWithTone_CheckedChanged(ByVal eventSender As
System.Object, ByVal eventArgs As System.EventArgs) Handles
optWithTone.CheckedChanged

If eventSender.Checked Then

pAlarmOption =
NokiaCLCalendar.CalendarAlarmType.CALENDAR_ALARM_W ITH_TONE

txtAlarmTime.Enabled = True

End If

End Sub

The control is a radio button and the error is - Option Strict On
disallows late binding.

Thanks in advance

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.