468,470 Members | 1,476 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,470 developers. It's quick & easy.

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

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
1 1721
jhardman
3,405 Expert 2GB
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.

Similar topics

2 posts views Thread by ensnare | last post: by
7 posts views Thread by TinTin | last post: by
4 posts views Thread by Paul M | last post: by
45 posts views Thread by Trevor Best | last post: by
5 posts views Thread by masood.iqbal | last post: by
2 posts views Thread by pob | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by kmladenovski | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.