dim str() as string
.....
如何判断一个数组是空的?

解决方案 »

  1.   

    Private Sub Command1_Click()
        Dim S() As String
        Dim intCount As Integer
        
        ReDim Preserve S(10) As String
        
        S(1) = "Test"
        For intCount = LBound(S) To UBound(S)
            If S(intCount) <> "" Then
                MsgBox "不为空"
                Exit For
            End If
        Next    
    End Sub
      

  2.   

    其中ReDim Preserve S(10) As String为重定义数组的大小,保留数组中原有的值
    LBound(S) 及 UBound(S)分别为数组的上限和下标
      

  3.   

    dim str() as string
    .....
    中间的过程并没有对str操作,后来再调用ubound(str)就出错了,我不想用on error goto...,怎么判断空的数组(不是空的字符串)呢?
      

  4.   

    我认为最简单的办法就是下面这两句写在一起:
    Dim str() string
    Redim str(0)