嵌套循环 [英] Nested Loops

查看:99
本文介绍了嵌套循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在试验嵌套的For ... Next循环。我的代码如下:


Dim i as Byte

Dim itm as Byte


for i = 0到9

Form = 0到9

''代码省略

下一页

下一页


我想知道在这个例子中首先完成哪个循环。


谢谢

Roshawn

Hi,

I am experimenting with nested For...Next loops. My code looks like this:

Dim i as Byte
Dim itm as Byte

For i = 0 to 9
For itm = 0 to 9
''code omitted
Next
Next

I''d like to know which loop will complete first in this example.

Thanks
Roshawn

推荐答案

你的内循环(itm)将首先完成执行。它将被执行总共10次,每次外循环一次(i)

" Roshawn" < UD **** @ bellsouth.net>在留言中写道

新闻:%2 **************** @ TK2MSFTNGP12.phx.gbl ...
Your inner loop(itm) will finish execution first. It will be executed 10
times in total, once through for each iteration of the outer loop (i)
"Roshawn" <ud****@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...


我正在试验嵌套的For ... Next循环。我的代码看起来像这样:

Dim i as Byte
Dim it as aste

对于i = 0到9
对于itm = 0到9
''代码省略
下一页

我想知道在这个例子中首先完成哪个循环。

谢谢
Roshawn
Hi,

I am experimenting with nested For...Next loops. My code looks like this:

Dim i as Byte
Dim itm as Byte

For i = 0 to 9
For itm = 0 to 9
''code omitted
Next
Next

I''d like to know which loop will complete first in this example.

Thanks
Roshawn



对于嵌套循环,内循环总是先完成。事实上,随着

嵌套任何东西,它总是最先完成的最内层项目然后

然后运行到最外层的元素。

Roshawn < UD **** @ bellsouth.net>在留言中写道

新闻:%2 **************** @ TK2MSFTNGP12.phx.gbl ...
With nested loops, the inner loop always completes first. In fact, with
nested anything, it is always the inner most item that completes first and
then works its way to the outer most element.
"Roshawn" <ud****@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...


我正在试验嵌套的For ... Next循环。我的代码看起来像这样:

Dim i as Byte
Dim it as aste

对于i = 0到9
对于itm = 0到9
''代码省略
下一页

我想知道在这个例子中首先完成哪个循环。

谢谢
Roshawn
Hi,

I am experimenting with nested For...Next loops. My code looks like this:

Dim i as Byte
Dim itm as Byte

For i = 0 to 9
For itm = 0 to 9
''code omitted
Next
Next

I''d like to know which loop will complete first in this example.

Thanks
Roshawn



感谢大家的快速回复。我还有另外一个问题要问。

关于我的示例代码,会像这样编写我的内循环导致

运行一次吗?


For i = 0 to 9

for itm = 0 to 0

''代码省略

下一页

下一页


或者最好是在不需要

内循环的情况下调用程序或函数?


谢谢,

Roshawn

Thank you to all for you prompt responses. I have another question to ask.
Regarding my example code, would writing my inner loop like this cause it
to run once?

For i = 0 to 9
For itm = 0 to 0
''code omitted
Next
Next

Or perhaps its best to call a procedure or function without the need of the
inner loop?

Thanks,
Roshawn


这篇关于嵌套循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆