Dynamic ASP Local Variables...

Discussion in 'ASP General' started by @sh, Jan 5, 2006.

  1. @sh

    @sh Guest

    I'd like to create a series of variables created dynamically, example such
    as this...

    For i = 1 to 5
    TheVariable & i = "blah"
    Next

    This would during the first loop create a variable called 'TheVariable1'
    with a value of 'blah'. Is this possible as so far I'm getting syntax
    errors?

    Cheers!
     
    @sh, Jan 5, 2006
    #1
    1. Advertising

  2. Use an array!
    Dim TheVariable[4]
    For i = 1 to 5
    TheVariable = "blah value #" & i
    Next

    Response.Write "For example, the third value is " & TheVariable[2]

    (Arrays are zero-based in vbscript, so the first element is 0, second is 1,
    and so on.)

    Ray at work

    "@sh" <> wrote in message
    news:dpj8u7$ggb$-infra.bt.com...
    > I'd like to create a series of variables created dynamically, example such
    > as this...
    >
    > For i = 1 to 5
    > TheVariable & i = "blah"
    > Next
    >
    > This would during the first loop create a variable called 'TheVariable1'
    > with a value of 'blah'. Is this possible as so far I'm getting syntax
    > errors?
    >
    > Cheers!
    >
     
    Ray Costanzo [MVP], Jan 5, 2006
    #2
    1. Advertising

  3. @sh

    @sh Guest

    That is so ridiculously obvious I'm blushing....sorry - I'm getting "haven't
    developed for a while" syndrome, where functions/commands begin to creep
    back into your mind, hehe

    Many thanks!


    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    message news:...
    > Use an array!
    > Dim TheVariable[4]
    > For i = 1 to 5
    > TheVariable = "blah value #" & i
    > Next
    >
    > Response.Write "For example, the third value is " & TheVariable[2]
    >
    > (Arrays are zero-based in vbscript, so the first element is 0, second is
    > 1, and so on.)
    >
    > Ray at work
    >
    > "@sh" <> wrote in message
    > news:dpj8u7$ggb$-infra.bt.com...
    >> I'd like to create a series of variables created dynamically, example
    >> such as this...
    >>
    >> For i = 1 to 5
    >> TheVariable & i = "blah"
    >> Next
    >>
    >> This would during the first loop create a variable called 'TheVariable1'
    >> with a value of 'blah'. Is this possible as so far I'm getting syntax
    >> errors?
    >>
    >> Cheers!
    >>

    >
    >
     
    @sh, Jan 5, 2006
    #3
  4. @sh

    Guest

    , Jan 10, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sullivan WxPyQtKinter
    Replies:
    10
    Views:
    684
    Antoon Pardon
    Nov 8, 2007
  2. Replies:
    9
    Views:
    985
  3. Tammo Tjarks
    Replies:
    2
    Views:
    294
    Tammo Tjarks
    Sep 13, 2007
  4. David Combs
    Replies:
    3
    Views:
    206
    Michele Dondi
    Aug 9, 2004
  5. king
    Replies:
    2
    Views:
    177
    Tad McClellan
    Jun 27, 2006
Loading...

Share This Page