|
-
Jul 14th, 2004, 08:08 AM
#1
Thread Starter
Frenzied Member
late binding
I don't fully understand the concept of late and early binding. I recently started using option strict and my code fell apart arrgh!
I fixed all of my errors except four of them and here is a sample of what I have left:
VB Code:
Private Sub tab_25_btnClearAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles tab_25_btnClearAll.Click
'Purpose : Clears the CU tabpage
Try
Client.ClearTab(sender.parent)
tab_25_optNo.Checked = True
Catch ex As Exception
ErrorMessage(ex.Message)
End Try
End Sub
the error is "option strict disallows late binding' and it highlights the "sender.parent" section. what can I do to correct this?
-
Jul 14th, 2004, 09:01 AM
#2
I wonder how many charact
Late-binding means the runtime must examine the generic object and try to coerce into the receiving container.
Early-Binding refers to explicity informing the compiler of what type of object the sender is, and what type of object the receiver is, so it can compile your app at build-time into the appropriate instructions, saving a whole hell lot of work for the runtime.
For your code, ask yourself, who is the Sender? Assume for example it was a TabPage.
VB Code:
'late-binding, compiler only knows Sender is an object (object has no property .parent)
'with option strict off, it includes code instructing
'runtime to call a "parent" method when it runs
Client.ClearTab(sender.parent)
'compiler now has instructions from you to cast the sender
'into a TabPage....which the compiler knows has a "parent" method
Client.ClearTab(DirectCast(Sender, TabPage).parent)
Last edited by nemaroller; Jul 14th, 2004 at 09:05 AM.
-
Jul 14th, 2004, 09:01 AM
#3
PowerPoster
Hi,
You need to put a CType in there somewhere. I'm not familiar with your paticular construction but the following is an excerpt from code I use
VB Code:
Dim intcount As Object
For Each intcount In Controls
If TypeOf intcount Is CheckBox Then
CType(intcount, CheckBox).Checked = True
End If
Next
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|