先定义了一个动态数组 譬如 :
dim arryTest() as Integer
......
问题: 怎么样才能判断这个动态数组没有没初始化过呢? 如果没有被初始话过(一般用Redim)的话 对这个 变量使用会出错的 包括 ubound lbound 函数请高手指点

解决方案 »

  1.   

    你每次都跟他Redim(0)阿,释放的时候也这样,0的这个不用
    从1开始用,每次测是不是索引最大为0即可
      

  2.   

    要不就Onerror罗,测错误信息,呵呵
      

  3.   

    如果包错就说明没有初始化 行么?
    dim ary() as string
    on error go to Err:
    i=ubound(ary)
    Err:
    msgbox"没有初始化"
      

  4.   

    on error 后会影响到后面的代码的 后面如果出显错误也会 跳到Err 呵呵
      

  5.   

    Function NotRedim(byref a) as Boolean
        on error resume next
        ubound(a)
        NotRedim=(err.Numeber<>0)
    End Function
      

  6.   

    sub test(a as integer)
        if Notredim then
           redim a(0)
        else
        'other code
        end if
    end sub
      

  7.   

    谢谢 youyiwuyi(有意无意) 大哥 呵呵,哎 vb其实有时候方便,有时候也挺麻烦的哦 呵呵
      

  8.   

    比客气,这也是我以前遇到的问题。在.net中直接可以用a.Lenght是否为0判断。