一、foreach语法 For Each...Next 语句对数组或集合中的每个元素重复执行一组语句。 For Each element In group [statements] [Exit For] [statements] Next [element] 参数介绍: element 用来枚举集合或数组中所有元素的变量。对于集合,element 可能是 Variant 变量、通用 Object 变量或任意指定的 Automation 对象变量。对于数组,element 只能是 Variant 变量。 group 对象集合或数组的名称。...[ 查看全文 ]
一、Do Until语法 第一种语法: Do Until 条件式 条件式为True为止,循环处理 Loop 第二种语法: Do 条件式为True为止,循环处理 Loop Until 条件式 二、Do Until的例子 下面分别针对如上的两种语法,给出相应的例子: 如下代码功能为:"单元格A1~A10内,填入1~10 i = 1 Do Until i = 11 Worksheets("Sheet1").Cells(i, 1).Value = i i = i + 1 Loop 如下代码的功能为:"单元格...[ 查看全文 ]
如下代码示例的功能是,在Excel中,通过VBA代码,读取XML文件中的内容。 Dim rst As ADODB.Recordset Dim stCon As String, stFile As String Dim i As Long, j As Long Set rst = New ADODB.Recordset stFile = "C:dzwebs.xml" stCon = "Provider=MSPersist;" With rst .CursorLocation = adUseClient .Open stFile, stCon, adOpenStatic, adLockReadOnly, adCmdFile Set .Ac...[ 查看全文 ]
数组数据排序的程序例子 <% ''*** build example array to show that this thing can sort ''*** alpha-numeric arrays Dim MyArray MyArray = Array(1,5,"shawn","says","hello"2m骺噃嶤123,12,98) MyArray = Sort(MyArray) For I = 0 to Ubound(MyArray) Response.Write MyArray(I) & "<br" & vbCRLF Next Response.End '...[ 查看全文 ]
在WORD中,我们可以通过修改WORD命令的方法,来方便地为WORD控件指定用户自定义的过程,完成或者转移(禁用)相应的内置方式.它的原理是利用相应宏名来置换过程的方法.在下面的三个部分中,我们可以体会其中的相同点与不同点。 Sub Example() Dim i As CommandBarControl For Each i In Application.CommandBars.FindControls If i.ID = 4 Then i.OnAction = "MySub" ’指定宏名 End If ...[ 查看全文 ]
PHP4.0中共有超过30个新的数组相关函数。其中很多通用函数允许你检查给定数组中是否存在特定对象、对数组元素计数、增加或删除元素,或对元素排序。 如果你有很大的一个数组,而所要完成的仅是找出一个存在的给定值,你可以使用in_array()以返回true 或 false。如下代码将输出“Not found in this array”——因为你将在$namesArray中寻找一个并不存在的“Alber ”。? $namesArray = array("Joe", "Ja...[ 查看全文 ]