Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA: Dictionary items to string array?

What I am trying to do is fairly straightforward. I want to get a list of all items (values) in a Dictionary, and save them in an array of strings.

I'd guess this code would work:

Sub PrintFilters(ByVal crit As Dictionary)
    Dim i() As String
    i = crit.Items()
    ' Do stuff with i
End Sub

However, I am getting a type mismatch on the third line. I am guessing that crit.Items()'s return value is some kind of list, an not an array. The MSDN pages do not mention what this method's return value's type is, though.

Is there a proper way to do this?

like image 989
Lee White Avatar asked Nov 19 '14 09:11

Lee White


1 Answers

I think is Variant type so try this:

Sub PrintFilters(ByVal crit As Dictionary)
    Dim i As Variant
    i = crit.Items()
    ' Do stuff with i
End Sub
like image 117
Mailkov Avatar answered Sep 17 '22 21:09

Mailkov