Option Strict ON and Dictionary obect

  • Thread starter Thread starter Howard Kaikow
  • Start date Start date
H

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
 
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
 
Howard,

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

Sorry

Cor
 
Cor Ligthert said:
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().
 
Back
Top