constant string array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • questionit
    Contributor
    • Feb 2007
    • 553

    constant string array

    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?
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by questionit
    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?

    Comment

    • questionit
      Contributor
      • Feb 2007
      • 553

      #3
      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?

      Originally posted by ADezii
      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?

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by questionit
        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.

        Comment

        • questionit
          Contributor
          • Feb 2007
          • 553

          #5
          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


          Originally posted by ADezii
          Give me a solid, concrete, example of what you are referring to.

          Comment

          Working...