By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,164 Members | 969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,164 IT Pros & Developers. It's quick & easy.

constant string array

100+
P: 553
Hi

How to declare a constant array variable of String type in VB/VBA

I've tried doing many things like this bt doesn't work

Const constStrArry() As String = ("string1"), ("string2")

with every similar method, i get error

is it possible to declare constant string array at all in VB?
Aug 13 '07 #1
Share this Question
Share on Google+
4 Replies


ADezii
Expert 5K+
P: 8,669
Hi

How to declare a constant array variable of String type in VB/VBA

I've tried doing many things like this bt doesn't work

Const constStrArry() As String = ("string1"), ("string2")

with every similar method, i get error

is it possible to declare constant string array at all in VB?
The concept behind a Constants is that they can be used in place of Literal Values and you set them equal to an expression, the expression being a Literal, other Constant, or any combination that includes all arithmetic or logical operators except Is. To the best of my knowledge, you cannot Declare a Constant as any type of an Array. Why would you even attempt something like this? What are you trying to accomplish?
Aug 13 '07 #2

100+
P: 553
I understand what you mean.

While doing some example, i came across that idea.. What if you need to check something against many values - Values belonged to same thing (same variable) . In that case, i would need an array constant.

I mean there is n orestriction the scenarious!

would you recommend using Enum instead in this case?

The concept behind a Constants is that they can be used in place of Literal Values and you set them equal to an expression, the expression being a Literal, other Constant, or any combination that includes all arithmetic or logical operators except Is. To the best of my knowledge, you cannot Declare a Constant as any type of an Array. Why would you even attempt something like this? What are you trying to accomplish?
Aug 13 '07 #3

ADezii
Expert 5K+
P: 8,669
I understand what you mean.

While doing some example, i came across that idea.. What if you need to check something against many values - Values belonged to same thing (same variable) . In that case, i would need an array constant.

I mean there is n orestriction the scenarious!

would you recommend using Enum instead in this case?
Give me a solid, concrete, example of what you are referring to.
Aug 13 '07 #4

100+
P: 553
Adezii

will come back to you on this one later as i am confused here a little bit.

VB Enums dont even take string values !

Thanks


Give me a solid, concrete, example of what you are referring to.
Aug 14 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.