www.3112.net > vBs 数组

vBs 数组

Public Function readFileToArray(strFileName As String) '=============================================== ' 读取文本文件到一个数组 ' @Param strFileName String 文件路径 ' @Retrun Array 文本文件的内容 ' @Ver 0.3 ' @Date 2015.9.29 '...

i = 0: nStr = "" Dim MyArray() Do a = InputBox("循环直到输入4为止") ReDim Preserve MyArray(i) MyArray(i) = a i = i + 1 Loop Until a = "4" For i = 0 To UBound(MyArray) nStr = nStr & MyArray(i) & "," Next MsgBox nStr 补充:------...

ubound:数组索引最大值。 lbound:数组索引最小值。 欲求数组实际长度,应该是ubound(数组)+1

下边是个简单的例子,示例如何在Function过程中返回数组 x=GetArr(9) '调用getarr过程返回10(0-9)个元素的数组,并赋值给x For i = 0 To UBound(x) '枚举刚才返回的数组 arrstr=arrstr & "GetArr(" & i & ")=" & x(i) & vbCrLf Next Msgbox arrs...

For i = LBound(a) To UBound(a) For j = i + 1 To UBound(a) If a(i) > a(j) Then '小到大排序 t = a(i) a(i) = a(j) a(j) = t End If Next Next

function strTobin(bytes,byval var)Dim xmldoc, nodeSet xmldoc = CreateObject("Msxml2.DOMDocument")Set node = xmldoc.CreateElement("binary")node.DataType = "bin.hex"for i=1 to len(var)result=result & hex(asc(mid(var,i,1)))nextnod...

数组传递参数使用的是指针,而VBS是没有指针这个概念的,即:数组不可能作为参数传递。

可以 aaa()是动态变量 首先声明动态变量:Dim aaa() 然后在要用的时候(改变它的时候)使用 Redim preserve aaa([一维下标 to ]一维上标[,[二维下标 to]二维上标……]) 如 Dim aaa() i = 2 Redim preserve aaa(i) aaa(2)="123" redim preserve aaa...

dim a(3) for i = 0 to UBound(a) if IsEmpty(a(i)) then j = j+1 end if next if j = UBound(a)+1 then msgbox "a("&UBound(a)&")是空数组" else msgbox "a("&UBound(a)&")不是空数组" end if ———————————— 用IsEmpty()函数,如果是空数组的话...

你定义的是一个二维数组,在VB中最多可以定义六十维。你定义了16个变量数组(VB数组是从0开始的)方法如下: Dim a(3,3) As Integer a(0,0) = 12 a(0,1) = 23 a(0,2) = 12 a(0,3) = 77 a(1,0) = 47 a(1,1) = 55 a(1,2) = 12 a(1,3) = 23 a(2,0) ...

网站地图

All rights reserved Powered by www.3112.net

copyright ©right 2010-2021。
www.3112.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com