网站制作学习网ASP→正文:For Each与For语句的区别
字体:

For Each与For语句的区别

ASP 2008/8/25 21:15:24  点击:不统计

它们之间的区别就是For Each...next可以在对象中循环,将一个对象中的数据从头到尾都取一遍;

For...next一般在知道步长和范围时使用,就是循环变量。例如:

Private Sub Commandl_Click()

Dim aa As Control

Dim i As Control

i = 1

For Each aa In Forml.Controls

If TypeName(aa) = "TextBox" Then

MsgBox"找到第"&i&"个"

i = i+1

End If

Next

End Sub

Private Sub Command2_Click()

Dim i As Integer

For i = 1 to 5

arr(i)=(i*3)

next

end sub

·上一篇:asp中的常量 >>    ·下一篇:截取、分割字符串 >>
推荐文章
最新文章