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

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

P: 24
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:

Expand|Select|Wrap|Line Numbers
  1. moora1 = 10
  2. moora2 = 20
  3. moora3 = 30
  4. moora4 = 40
  5. moora5 = 50
  6. moora6 = 60
  7. moora7 = 70
  8.  
  9. for i = 1 to 7
  10. response.write moora&i&"<br>"
  11. next
  12.  
Thanks in advance.
Feb 2 '11 #1
Share this Question
Share on Google+
1 Reply


jhardman
Expert 2.5K+
P: 3,405
This would work for session variables
Expand|Select|Wrap|Line Numbers
  1. session("moora1") = 10
  2. 'Etc
  3.  
  4. For x = 1 to 7
  5.    Response.write session("moora" & x)
  6. Next
but really you need to be using arrays
Expand|Select|Wrap|Line Numbers
  1. moora(0) =10
  2. moora(1) = 20
  3. 'Etc
  4.  
  5. For x = 0 to 6 
  6.    Response.write moora(x)
  7. Next
let me know if this helps.

Jared
Feb 2 '11 #2

Post your reply

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