|
-
Apr 27th, 2005, 06:01 PM
#1
Thread Starter
Fanatic Member
Late Binding?
Hello all,
I tried making my application with Option Strict On. Arg!! I understand the implicit conversion errors and functions that have to have their return type declared, but what is it with late binding? I can't declare a variable of type [some object type] and then assign an object to it? That seems really stupid.
Lets say I try to do this:
VB Code:
Dim item As ListViewItem
item = sender.GetItemAt(e.X, e.Y)
I tried making it work like this:
VB Code:
Dim item As ListViewItem = sender.GetItemAt(e.X, e.Y)
How could I do what I am trying to do with Option Strict On?
Thanks.
In life you can be sure of only two things... death and taxes. I'll take death.
-
Apr 27th, 2005, 06:17 PM
#2
Re: Late Binding?
Presumably you're executing this code in an Event, so Sender is of type Object.
To support Option Strict you need to cast the sender variable to a ListView, i.e.
VB Code:
Dim item As ListViewItem = CType(sender, ListView).GetItemAt(e.X, e.Y)
Regards,
- Aaron.
-
Apr 27th, 2005, 06:41 PM
#3
Thread Starter
Fanatic Member
Re: Late Binding?
Once again. Thank you Aaron!
In life you can be sure of only two things... death and taxes. I'll take death.
-
Apr 27th, 2005, 08:57 PM
#4
PowerPoster
Re: Late Binding?
Hi,
FYI DirectCast is substantially faster than CType. Convert. is slightly faster again but is not applicable to your requirement.
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.
-
Apr 27th, 2005, 09:30 PM
#5
Addicted Member
Re: Late Binding?
FYI DirectCast is substantially faster than CType. Convert. is slightly faster again but is not applicable to your requirement
I was under the impression that CType was faster than Convert because CType is compliled inline whereas Convert requires a function call.
-
Apr 28th, 2005, 03:44 PM
#6
Thread Starter
Fanatic Member
Re: Late Binding (Speed)?
I would be very interested in seeing which is faster. Any body want to run some tests?
In life you can be sure of only two things... death and taxes. I'll take death.
-
Apr 28th, 2005, 05:40 PM
#7
PowerPoster
Re: Late Binding?
Hi,
Tests have been posted in at least one other thread. DirectCast is 4 or 5 times faster than CType. Convert, when you can use it, is 5% faster than DirectCast.
have a look at
http://www.vbforums.com/showthread.p...ght=DirectCast
It really is a question of horses for courses.
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
|