zoukankan      html  css  js  c++  java
  • VBS基础篇

     数组变量:有时需要向一个单一的变量赋于多个值,那么您可以创建一个可包含一系列值的变量,这种变量被称为数组。

    '静态数组
    dim a(2)
    a(0)="George"
    a(1)="john"
    a(2)="Ethon"
    for i =0 to 2
        msgbox a(i)
    next
    for i =0 to ubound(a) 'ubound函数,返回指定数组维数的最大可用下标
        msgbox a(i)
    next
    
    '动态数组 dim a() for i = 0 to 2   redim preserve a(i) 'ReDim语句,用于过程级声明动态数组变量并分配或重新分配存储空间   a(i)=i+1
      msgbox a(i) next
    '动态二维数组
    Dim MyArray() '首先定义一个一维动态数组
    ReDim MyArray(1,1) '重新定义该数组的大小
    MyArray(0,0) = "A" '分别为数组赋值
    MyArray(0,1) = "a"
    MyArray(1,0) = "B"
    MyArray(1,1) = "b"
    ReDim Preserve MyArray(1,2) '重新定义该数组的大小
    MyArray(0,2) = "A-a" '继续为数组赋值
    MyArray(1,2) = "B-b"
    MsgBox UBound(MyArray,1)
    MsgBox UBound(MyArray,2)
    For i=0 To UBound(MyArray,1)
        For j=0 To UBound(MyArray,2)
            MsgBox MyArray(i,j) '循环遍历数组,并输出数组值
        Next
    Next
    
    
    Dim MyArray() '首先定义一个一维动态数组
    ReDim MyArray(3) '重新定义该数组的大小
    MyArray(0) = "" '分别为数组赋值
    MyArray(1) = ""
    MyArray(2) = ""
    MyArray(3) = ""
    ReDim Preserve MyArray(5) '重新定义该数组的大小
    MyArray(4) = "" '继续为数组赋值
    MyArray(5) = ""
    For i=0 To UBound(MyArray)
        MsgBox MyArray(i) '循环遍历数组,并输出数组值
    Next
  • 相关阅读:
    joblib to implement multi-progress
    python排序
    回归评估:R2
    评估曲线
    模型融合:Stacking
    排列重要性
    单点登陆
    特征漂移检测
    python数组切片
    docker -ti
  • 原文地址:https://www.cnblogs.com/wakey/p/5728192.html
Copyright © 2011-2022 走看看