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
    
     
    

      

     

     

     

     

  • 相关阅读:
    [bzoj4893]项链分赃
    [Spoj]Counting Divisors (cube)
    [Noi2016]国王饮水记
    [Noi2016]网格
    [Noi2016]优秀的拆分
    [Noi2016]区间
    [Noi2015]寿司晚宴
    Codeforces Round #411 (Div. 2)
    VK-Cup2017 Wild Card Round 2
    [Noi2015]小园丁和老司机
  • 原文地址:https://www.cnblogs.com/Daluo20200515/p/12944292.html
Copyright © 2011-2022 走看看