Y
YYZ
After reading many messages in this group, it seems that the preferred
setting for this is ON. Okay, I did that in my project (first with
..Net -- long time VB6 developer) and now a bunch of problems have
cropped up. Most are easy to solve with using an explicit type cast
cType(whatever, whatever type), but some aren't.
Situation 1: I've got code that tries to get the itemkey of the
selected item in a combobox.
cmbDecCBrwrM1.SelectedItem.ItemKey
That worked before, but now, "Option Strict On disallows late binding"
-- well, I'm not sure how to get the item key of the selected item,
because now selecteditem only has the "GetType" default method in its
intellisense. I'm not sure what I could type this to to get an itemkey
property...
Situation 2: I've created a collection class (stolen, actually, from
Microsoft I believe) that allows me to have a strongly typed
colleciton. I solved a couple of problems by overloading the remove
method to handle an integer or a string, and also Type-ing some other
things...but here is what is left:
Public ReadOnly Property NewEnum() As stdole.IUnknown
Get
'this property allows you to enumerate
'this collection with the For...Each syntax
NewEnum = mCol.GetEnumerator
End Get
End Property
Error is on the NewEnum = mCol.GetEnumerator line, and the error is
that it can't convert iUnknown to iEnumerator. I think I solved this
one by changing the declaration of the proc to ... As
System.Collections.IEnumerator But I don't know if that messed
everything up because I can't run the project to test it because of the
other errors.
Finally, is using Option Strict On really that good of an idea if all
you do is do some explicit CType functions? I mean, if, while running
your program, it blows up on something without Option Strict On, it
wouldn't help to have Option Strict on and just CType that same line,
because you are still "going out on a limb" and trusting that the
object you are CTyping really IS the type of object you want...right?
Any pointers would be appreciated.
Matt
setting for this is ON. Okay, I did that in my project (first with
..Net -- long time VB6 developer) and now a bunch of problems have
cropped up. Most are easy to solve with using an explicit type cast
cType(whatever, whatever type), but some aren't.
Situation 1: I've got code that tries to get the itemkey of the
selected item in a combobox.
cmbDecCBrwrM1.SelectedItem.ItemKey
That worked before, but now, "Option Strict On disallows late binding"
-- well, I'm not sure how to get the item key of the selected item,
because now selecteditem only has the "GetType" default method in its
intellisense. I'm not sure what I could type this to to get an itemkey
property...
Situation 2: I've created a collection class (stolen, actually, from
Microsoft I believe) that allows me to have a strongly typed
colleciton. I solved a couple of problems by overloading the remove
method to handle an integer or a string, and also Type-ing some other
things...but here is what is left:
Public ReadOnly Property NewEnum() As stdole.IUnknown
Get
'this property allows you to enumerate
'this collection with the For...Each syntax
NewEnum = mCol.GetEnumerator
End Get
End Property
Error is on the NewEnum = mCol.GetEnumerator line, and the error is
that it can't convert iUnknown to iEnumerator. I think I solved this
one by changing the declaration of the proc to ... As
System.Collections.IEnumerator But I don't know if that messed
everything up because I can't run the project to test it because of the
other errors.
Finally, is using Option Strict On really that good of an idea if all
you do is do some explicit CType functions? I mean, if, while running
your program, it blows up on something without Option Strict On, it
wouldn't help to have Option Strict on and just CType that same line,
because you are still "going out on a limb" and trusting that the
object you are CTyping really IS the type of object you want...right?
Any pointers would be appreciated.
Matt