Home All Groups Group Topic Archive Search About

Option Strict ON and Dictionary obect

Author
4 Apr 2005 3:23 PM
Howard Kaikow
Using Option Strict On, how does one deal with the two lines I've marked
with comments?


Dim dict As Scripting.Dictionary
Dim i As Integer
Dim vnt As Object
dict = New Scripting.Dictionary
With dict
..CompareMode = Scripting.CompareMethod.BinaryCompare
..Add("a", "a")
..Add("A", "A")
vnt = .Items    ' Problem line
End With
For i = 0 To UBound(vnt)
System.Diagnostics.Debug.WriteLine(VB6.TabLayout(i, vnt(i)))    ' Perhaps,
problem line
Next i

Author
4 Apr 2005 3:40 PM
Cor Ligthert
Howard,

Are you sure it is working without option strict.

I would assume something as
\\\
Dim dict As Scripting.Dictionary
Dim i As Integer
Dim vnt() As Object
dict = New Scripting.Dictionary
With dict
.CompareMode = Scripting.CompareMethod.BinaryCompare
.Add("a", "a")
.Add("A", "A")
vnt = Directcast(.Items,Object())
End With
  For i = 0 To UBound(vnt)
    System.Diagnostics.Debug.WriteLine(VB6.TabLayout(i,
Directcast(vnt,Object())(i).ToString()))
Next i
///
I hope this helps,

Cor
Author
4 Apr 2005 3:46 PM
Cor Ligthert
Howard,

The last directcast is of course bs. the toString does it all.

Sorry

Cor
Author
4 Apr 2005 11:11 PM
Howard Kaikow
"Cor Ligthert" <notmyfirstn***@planet.nl> wrote in message
news:%23PpirySOFHA.3512@TK2MSFTNGP15.phx.gbl...
> Howard,
>
> Are you sure it is working without option strict.

Yes.
>
> I would assume something as

Thanx.

I had been awake for about 20 hours, groggier than usual (I just woke up
about 15 minutes ago),  when I did the code and missed out that I had to use
Object() instead of Object. I was just casting to Object, not Object().