Cast variant array to specific type array

I am a bit stumped with the syntax for this, can anyone give me some clues?

I have a Dictionary full of objects of the same type, I want to write a method that returns an array of that specific type by somehow casting Dictionary.Values(). I am hoping that the answer is not to have to Dim an array of my specific type and populate it by iteration but I can obviously do that if there is no better way.

I think there is no other way to do it.

dim myClassArray() as myClass for each value as Variant in myDict.Values myClassArray.append value next

Perhaps you can try to check if you can avoid to have a such array and just cast values when they are needed.
Or file a feature request for the ability to cast arrays.

Thanks Massimo, I found nothing in the language reference, a few unhelpful mentions in Google searched and so I had a feeling that would be the answer but I wanted to make sure that I hadn’t missed some special trick. I can’t really avoid having the array as I am coding some ‘typesafe’ collections based on sub classed dictionaries and each collection needs a ToArray() method for iteration using ‘for each’ - I have done it as you have suggested.