zoukankan      html  css  js  c++  java
  • VB 中的数组使用

    一、数组概念

    一组相同数据类型的集合

    二、声明数组索引的缺省下届

    语法

    Option Base {0 | 1}

    模块级别中使用,用来声明数组下标的缺省下界。

    三、声明数组

    1、声明静态数组,数组的大小不变

    dim  nodes(10)  as string   

    2、声明动态数组,数组的大小可以改变

    dim nodes() as string

    redim nodes(20) as string

    四、数组元素赋值

    数组中的各元素,必须个别指定其值。

    实例:

    将字符串spath=  “01模块测试2模块专用9扫描类4.A4纸扫描仪(未评审)1.外观结构” 以“” 为界划分为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
    
     
    

      

     

     

     

     

  • 相关阅读:
    js对象
    实习经历日志02
    前端实习经历日志01
    js变量提升
    WebApls-元素(offset, client, scroll)
    WebApls-Bom
    WebApls-DOM的核心总结
    WebApls-节点01
    javascript-
    Javascript-字符串对象
  • 原文地址:https://www.cnblogs.com/Daluo20200515/p/12944292.html
Copyright © 2011-2022 走看看