Issue with Dictionary.Exists

Gringoire

Board Regular
Joined
Nov 18, 2016
Messages
71
Office Version
  1. 365
Platform
  1. Windows
Hello guys,
it seems a stupid issue but I can't go out of this even after googling for a while. Here is my code:

VBA Code:
Option Explicit
Private m_timeList As Scripting.Dictionary
'Timer class

Private Sub Class_Initialize()
    Set m_timeList = New Scripting.Dictionary
End Sub

Function blockStart(nome As String)
    'Start time
    m_timeList.Add getTime, nome
End Function

Function blockStop(nome As String)
    'Stop time
    m_timeList.Add getTime, nome & "§"
End Function

After running the code some time to fill the m_timeList dictionary, this is what Immediate windows say:

Rich (BB code):
?m_timeList.Items(1)
prova1§
?m_timeList.Keys(1)
 1194768,0593771 
?m_timeList.Items(2)
prova2
?m_timeList.Keys(2)
 1194768,059384 
?m_timeList.Exists("prova2")
False
?m_timeList.Exists(m_timeList.Items(2))
False
?m_timeList.Exists("prova1§")
False

For sure the Keys "prova2" or "prova1§" exist, because i can print it, but when i use .Exists, it always returns FALSE.
For sure I'm doing some conceptual error but I do not understand which one...

thanks for your help.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
The Dictionary object is case-sensitive. Could this be the issue?
 
Upvote 0
Sorry for disturbing you for the silly mistake.
I just added the Key at the Item place and Item at the Key place! :oops:
However the pause from coding I got to write this post gave me the right view to see the error.

Sometime even just writing down the issue in the forum is a help by itself!
 
Upvote 0
Solution
That's great, I'm glad you were able to solve your issue.

Cheers!
 
Upvote 0

Forum statistics

Threads
1,215,077
Messages
6,122,991
Members
449,094
Latest member
masterms

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top