Results 1 to 3 of 3

Thread: Accessing a variable name by a variable

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Accessing a variable name by a variable

    I know you can call a function by name or by it's name in a variable. My question is can that also be done for named variables or Const's?

    To illustrate

    I have the following data strings in my code:

    Private Const s1 = "some text here"
    Private Const s2 = "some text here"
    Private Const s3 = "some text here"
    Private Const s4 = "some text here"
    etc
    etc
    Private Const s356 = "some text here"

    I cannot put the data in an array. That is out of the question. I can only put the data in a series of Const's like shown above.

    I need some way, if possible, to access the data from each Const without having to explicitly namming each Const. Something like this

    For q = 1 to 356
    MyDataString = MyDataString & "s" & q
    Next q

    Now I know the above will put "s1", "s2", "s3",...."s356" in MyDataString but I need the actual data from these Const's.

  2. #2
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Accessing a variable name by a variable

    No you cannot. Why is an array out of the question?????

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Accessing a variable name by a variable

    It isn't anymore. I thought perhaps I wouldn't be able to use one but I did figure out how to go about my problem using an array.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width