有人用VB的错误处理机制来做的.public function test(t() as byte) as boolean on error goto errhandle: dim i as integer for i=lbound(t) to lbound(t) test=true next exit function errHandle: test=false
还是帖出来吧:Function IsReDim(ByRef MyArray() As Variant) As Boolean On Error GoTo Z Dim szTmp szTmp = Join(MyArray, ",") IsReDim = LenB(szTmp) > 0 Exit Function Z: IsReDim = False End FunctionIsReDim判断数组是不是被分配过,如果是动态数组被Erase了,将返回False使用例子: If IsReDim(uArray) Then 'uArray里面有数据 Else 'uArray里面没有数据 End If 你用的时候只要这样调用就可以了: If IsReDim(bytData) Then 'bytData里面有数据 Else 'bytData里面没有数据 End If
on error goto errhandle:
dim i as integer
for i=lbound(t) to lbound(t)
test=true
next
exit function
errHandle:
test=false
判断数组是否被分配的VB函数
On Error GoTo Z
Dim szTmp
szTmp = Join(MyArray, ",")
IsReDim = LenB(szTmp) > 0
Exit Function
Z:
IsReDim = False
End FunctionIsReDim判断数组是不是被分配过,如果是动态数组被Erase了,将返回False使用例子:
If IsReDim(uArray) Then
'uArray里面有数据
Else
'uArray里面没有数据
End If
你用的时候只要这样调用就可以了:
If IsReDim(bytData) Then
'bytData里面有数据
Else
'bytData里面没有数据
End If