# Vba declare string array constants at module level



## balloon_tom (Jan 5, 2006)

Hi all,
I have a global string array declared at module level as:

Public Pg() as string

as it it used in several subs. I redim and set the values, which are always the same, in each sub that uses the array:

ReDim Pg(4) as string
Pg(0) = "TRIM"
Pg(1) = "FIRST"
Pg(2) = "SECOND"
Pg(3) = "THIRD"

I've tried to set the values as constants in the module level so that I don't need to re-assign these values in each sub that uses them, but everything I have tried causes syntax errors.

Is there a way to declare these values as constants at module level?

Thanks,
Tom


----------



## pcdebol (Mar 2, 2009)

I'm a little out of my language here but why not throw it into a public class. I assume you can do that in VB. If I'm way off base flame me and laugh.


----------



## pvc_ (Feb 18, 2008)

for redim, you don't need to specify a type. 


try this instead: Public Pg() as string = {"TRIM", "First", ...}


----------

