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
"RadioButto n" first:
----
If DirectCast(even tSender, RadioButton).Ch ecked 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_Che ckedChanged(ByV al eventSender As
System.Object, ByVal eventArgs As System.EventArg s) Handles
optWithTone.Che ckedChanged
If eventSender.Che cked Then
pAlarmOption =
NokiaCLCalendar .CalendarAlarmT ype.CALENDAR_AL ARM_WITH_TONE
txtAlarmTime.En abled = True
End If
End Sub
The control is a radio button and the error is - Option Strict On
disallows late binding.
Thanks in advance