0

I have the following declaration in a function in VBA:

Set dict = CreateObject("Scripting.Dictionary")

When I try to return dict using the code GetDates = dict I get an error. Can someone help please?

Thanks!

Jacob
  • 41,721
  • 6
  • 79
  • 81
Paul
  • 177
  • 1
  • 5
  • 14
  • Welcome to SO, have a look at the [FAQ](http://stackoverflow.com/faq#howtoask) – Jacob Jul 21 '11 at 15:00
  • This question is essentially a duplicate of [Can a VBScript function return a dictionary?](http://stackoverflow.com/questions/4038058/can-a-vbscript-function-return-a-dictionary) and [VBScript: How to utiliize a dictionary object returned from a function?](http://stackoverflow.com/questions/140002/vbscript-how-to-utiliize-a-dictionary-object-returned-from-a-function) - VBA and VBScript are the same in this regard. – Helen Jul 21 '11 at 17:21

1 Answers1

3
Set GetDates = dict

You have to use Set.

Jacob
  • 41,721
  • 6
  • 79
  • 81
  • Thanks for your reply. That doesn't appear to work. I am calling it like this: ResetDates = GetDates(1, 12, "Client Next Reset Date", "Client Roll Date", "Cur Not.") – Paul Jul 21 '11 at 15:01
  • where Set ResetDates = CreateObject("Scripting.Dictionary") – Paul Jul 21 '11 at 15:02
  • vCould you update your question with the extra code and quote your error message? – Jacob Jul 21 '11 at 15:04
  • 2
    You need one more "Set": `Set ResetDates = GetDates(1, 12, ..., "")` – mwolfe02 Jul 21 '11 at 15:06
  • Everytime you want to associate a variable with an (dictionary) object, you need to use SET. – Jacob Jul 21 '11 at 15:08
  • @Paul, if this worked, then click on the check mark that appears on the upper left of this answer to 'accept it'. Thanks. – Gaijinhunter Jul 28 '11 at 07:54