Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Infinite FOR loop issue
#4
Not Solved
As far as i have learned,
For Loop in Vbscript is a conditional statement which iterates based on the condition specified. Unlike C & Java the variable in the iteration is not updated during execution.

The loop is not exiting because i value has reached 5 but because you have specified only 5 iterations.
Code:
j=5
for i = 1 to j
j=j+1
Next
In this case if you give j=10, it will exit after 10 iterations. Now, the increment done on j is not being updated to the variable on the conditional statement.

You could do this in Java or C without specifying the end , for eg :
Code:
for(i=0;;i++)
this will keep executing till it reaches the maximum value for the defined datatype. There is no such thing called Infinity.

As far as i know, in vbscript, you could use the while loop to create an unconditional iteration.

For eg:
Code:
i=2
Do
j=j+1
msgbox j
Loop Until i=1

Probably, if the For Loop in vbscript could be pushed to be so, i would really like to learn about it.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply


Messages In This Thread
Infinite FOR loop issue - by Sivapratha - 03-28-2013, 10:37 AM
RE: Infinite FOR loop issue - by basanth27 - 03-28-2013, 03:26 PM
RE: Infinite FOR loop issue - by Sivapratha - 03-28-2013, 04:38 PM
RE: Infinite FOR loop issue - by basanth27 - 04-01-2013, 09:44 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Infinit loop Suma Parimal 1 2,755 05-29-2014, 01:22 PM
Last Post: basanth27
  Exit Do loop shipu 1 4,871 12-20-2013, 06:33 AM
Last Post: basanth27
  Do Until loop returning failure mitch 0 3,581 05-27-2011, 12:20 AM
Last Post: mitch
  If Then statement inside For loop Mala 3 4,087 02-23-2011, 10:13 PM
Last Post: basanth27
  For loop after couple of If then else statements Mala 4 5,136 02-16-2011, 06:37 AM
Last Post: Mala

Forum Jump:


Users browsing this thread: 1 Guest(s)