• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 395
  • Last Modified:

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

0
peispud
Asked:
peispud
  • 2
1 Solution
 
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
 
Dale FyeCommented:
but you could do:

Dim FilenameArray() as string

FilenameArray = Split("a,b,c,d,e", ",")
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now