在VBscript中执行while / Do的区别

时间:2013-01-04 05:50:14

标签: javascript vbscript

执行直到循环 vbscript 之间有什么区别, javascript中的等效循环语句是什么

3 个答案:

答案 0 :(得分:4)

do whiledo until之间的唯一区别是,只要条件为真,第一个循环就会循环,而第二个循环只要条件为假就会循环。

在Javascript中,您使用do {} while()while() {}。例如:

var cnt = 0;
do {
  cnt++;
} while (cnt < 10);

var cnt = 0;
while (cnt < 10) {
  cnt++;
}

使用!运算符取消条件以获得与until相同的功能。

答案 1 :(得分:2)

while while,(条件为真时重复代码)

Do While i>10
  some code
Loop

Do
  some code
Loop While i>10

直到,(重复代码直到条件变为真)

Do Until i=10
  some code
Loop

Do
  some code
Loop Until i=10

Javascript角,

while ( i>10)
{
   some code
}

,或者

do
{
   some code
} while (i>10);

希望你有这个想法

答案 2 :(得分:-1)

Google is your frienddo-while循环执行 1或更多次,而while循环执行 0或更多次。

来自MSDN:

While   Required unless Until is used. Repeat the loop until condition is False.
Until   Required unless While is used. Repeat the loop until condition is True.