Declare string array in one line

Hi

I am trying to make this work in Microsoft Access 2013.  (see below.)  
I would like declare a defined array very much like the second line of the code.

Thank you.

Dim fileNameArray() As String
   fileNameArray = Array("a", "b", "c", "d", "e")

Open in new window

peispudAsked:
Who is Participating?
 
Dale FyeConnect With a Mentor Commented:
but you could do:

Dim FilenameArray() as string

FilenameArray = Split("a,b,c,d,e", ",")
0
 
BitsqueezerCommented:
Hi,

that's not possible as the Array function only produces variant arrays. That gives you the possibility to create mixed datatype arrays but for the price that you can't create string arrays with this function. So your code works with this if you can live with using variants:
Dim fileNameArray() As Variant
   fileNameArray = Array("a", "b", "c", "d", "e")

Open in new window


Cheers,

Christian
0
 
peispudAuthor Commented:
Both answers were correct,  but you NAILED it Mr Fye.

I wasn't aware of the split function.  Perfect!

Thank you
0
 
Dale FyeCommented:
glad I could help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.