VBA-tools / VBA-Dictionary

Drop-in replacement for Scripting.Dictionary on Mac
MIT License
348 stars 89 forks source link

Compilation problem? #11

Closed JNurick closed 9 years ago

JNurick commented 9 years ago

Hi Tim, I've just downloaded the latest VBA-Dictionary-master.zip. 1) When I open VBA-Dictionary Specs.xlsm and click on Run Specs, I get Error 5 on this line

    dict_pDictionary.CompareMode = Value

in Public Property Let CompareMode. Here's the call stack:

call stack

At this point dict_pDictionary.Count is 1.

So I tried stepping through the code and found something that seems strange. In AllSpecs(), at the first call to CreateDirectionary(UseNative), with UseNative=False:

Public Function CreateDictionary(Optional UseNative As Boolean = False) As Object
    If UseNative Then
        Set CreateDictionary = CreateObject("Scripting.Dictionary")
    Else
        Set CreateDictionary = New Dictionary
    End If
End Function

2) If UseNative is true, this returns a Scripting.Dictionary. If UseNative is False, it returns a new (VBA-)Dictionary. But the compiler constant UseScriptingDictionaryIfAvailable is True, which means that (in Windows) VBA-Dictionary uses a Scripting.Dictionary - IOW, it appears, your test code doesn't test the class.

To overcome this I set UseScriptingDictionaryIfAvailable=False. This leads to compile errors, starting with an undeclared variable Key in dict_AddKeyValue().

Windows 7, Excel 2010

Over to you!

John

timhall commented 9 years ago

Yeah, you caught me. I broke the build while namespacing the code and saving it to test on my Mac, whoops!