一、数组概念
一组相同数据类型的集合
二、声明数组索引的缺省下届
语法
Option Base {0 | 1}
在模块级别中使用,用来声明数组下标的缺省下界。
三、声明数组
1、声明静态数组,数组的大小不变
dim nodes(10) as string
2、声明动态数组,数组的大小可以改变
dim nodes() as string
redim nodes(20) as string
四、数组元素赋值
数组中的各元素,必须个别指定其值。
实例:
将字符串spath= “01模块测试\02模块专用\09扫描类\04.A4纸扫描仪(未评审)\01.外观结构” 以“\” 为界划分为5个字符串保存到数组nodes() 中
Option Base 1
Dim nodes() As String '用于保存节点的名称
'MsgBox InStr(tempPath, "\")
numOfNodes = 0
While (InStr(tempPath, "\") > 0)
numOfNodes = numOfNodes + 1
tempPath = Right(tempPath, Len(tempPath) - InStr(tempPath, "\"))
Wend
'将路径保存为数组
ReDim nodes(numOfNodes + 1)
tempPath = spath
For i = 1 To numOfNodes
nodes(i) = Left(tempPath, InStr(tempPath, "\") - 1)
tempPath = Right(tempPath, Len(tempPath) - InStr(tempPath, "\"))
Next
nodes(numOfNodes + 1) = tempPath
金华威数码科技有限公司(简称“金华威”)成立于2008年5月,是一家专注于为IC
Prev post