www.3112.net > vBs 数组

vBs 数组

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 补充:------...

你定义的是一个二维数组,在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) ...

按照你题目的要求,循环已经是最快的效率了,如果你的是字符串那么效率可以更快,有问题就百度HI我 Dim a, b a = Array(11, 12, 13, 14, 15) b = Array(21, 22, 23, 24, 25) Dim n n = Val(InputBox("输入")) Dim i Dim f f = 3 For Each i In a...

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

下边是个简单的例子,示例如何在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

t 是临时变量,用于两变量交换时保存一个变量的值。因为一个变量或一个数组元素只能保存一个值,要交换时不用一个临时变量存放时怎么行?

vbs数组的作用,用我的话来说,就是为了"批量","归纳"和"现行矩阵" 数组 Option Explicit Dim arr(3),i For i= 0 To 3 arr(i) = InputBox (" 输入第 "&i+1&" 个数 ","") ' 输入 4 个数 Next MsgBox " 您输入的数组是: " & Join (arr," ") ' 输出...

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()函数,如果是空数组的话...

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

网站地图

All rights reserved Powered by www.3112.net

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