在VB中如何得到数组的长度?

解决方案 »

  1.   

    Dim str(30) As String
    MsgBox LBound(str)
    MsgBox UBound(str)
      

  2.   

    UBound(數組變量,維數)如:    Dim AA() As String
        
        ReDim AA(3, 9) As String
        
        Debug.Print UBound(AA, 1), UBound(AA, 2), UBound(AA)輸出為:
     3             9             3
      

  3.   

    to 楼上们
    如果一个数组没有被redim过Dim str() As String
    MsgBox LBound(str)
    MsgBox UBound(str)是不是会报错?