Option Strict ON and Dictionary obect

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
 
C

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
 
C

Cor Ligthert

Howard,

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

Sorry

Cor
 
H

Howard Kaikow

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().
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top