手机
当前位置:查字典教程网 >编程开发 >ASP教程 >asp For Each Next 用法与For Each实例教程
asp For Each Next 用法与For Each实例教程
摘要:在ForEach...Next循环类似,对于...Next循环。而不是重复陈述的指定的次数,每名...Next循环重复的对象集合为数组中的每...

在For Each ... Next循环类似,对于... Next循环。而不是重复陈述的指定的次数,

每名... Next循环重复的对象集合为数组中的每个元素的声明(或每个项目)。

下面的代码片断创建下拉列表中选择其中一个数组元素:

Select ActionSelect AllTry It<%
Dim bookTypes(7) 'creates first array
bookTypes(0)="Classic"
bookTypes(1)="Information Books"
bookTypes(2)="Fantasy"
bookTypes(3)="Mystery"
bookTypes(4)="Poetry"
bookTypes(5)="Humor"
bookTypes(6)="Biography"
bookTypes(7)="Fiction"

Dim arrCars(4) 'creates second array
arrCars(0)="BMW"
arrCars(1)="Mercedes"
arrCars(2)="Audi"
arrCars(3)="Bentley"
arrCars(4)="Mini"

Sub createList(some_array) 'takes an array and creates drop-down list
dim i
response.write("<select name=""mylist"">" & vbCrLf) 'vbCrLf stands for

Carriage Return and Line Feed
For Each item in some_array
response.write("<option value=" & i & ">" & item & "</option>" &

vbCrLf)
i = i + 1
Next 'repeat the code and move on to the next value of i
response.write("</select>")
End Sub

'Now let's call the sub and print out our lists on the screen
Call createList(bookTypes) 'takes bookTypes array as an argument
Call createList(arrcars) 'takes arrCars array as an argument
%>

【asp For Each Next 用法与For Each实例教程】相关文章:

asp从缓存读数据实例

ASP数据岛操作类

filesystemobject组件的用法示例

asp组件编写准备工作

ASP中FCKEditor编辑器的设置教程

asp调用c#编制的com组件实例

存储过程里的递归 实现方法

asp For Next 循环语句语法与实例

不用模板,只用ASP+FSO生成静态HTML页的一个方法

Utf-8和Gb2312乱码问题的终结

精品推荐
分类导航