How to loop through arranged variables m1,m2,m3,m4,...?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • goodamr
    New Member
    • Jun 2007
    • 24

    How to loop through arranged variables m1,m2,m3,m4,...?

    Hi,

    I have 7 variables named moora1, moora2, moora3,.., moora7 and has its corresponding values. I want to loop through them and print its corresponding values, how can I achieve that.

    The following code dosen't work:

    Code:
    moora1 = 10
    moora2 = 20
    moora3 = 30
    moora4 = 40
    moora5 = 50
    moora6 = 60
    moora7 = 70
    
    for i = 1 to 7
    response.write moora&i&"<br>"
    next
    Thanks in advance.
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    This would work for session variables
    Code:
    session("moora1") = 10
    'Etc
    
    For x = 1 to 7
       Response.write session("moora" & x)
    Next
    but really you need to be using arrays
    Code:
    moora(0) =10
    moora(1) = 20
    'Etc
    
    For x = 0 to 6 
       Response.write moora(x)
    Next
    let me know if this helps.

    Jared
    Last edited by jhardman; Feb 2 '11, 04:27 PM.

    Comment

    Working...