vb6如何判断任意类型动态数组为空(想做个判断为空的函数)
vb6如何判断任意类型动态数组为空想做个判断为空的函数,在函数内部用Ubound判断数组长度,通过捕捉错误,判断数组是否为空,问题是想把这个函数做成可判断任意类型数据的动...
vb6如何判断任意类型动态数组为空
想做个判断为空的函数,在函数内部用 Ubound判断数组长度,通过捕捉错误,判断数组是否为空,问题是想把这个函数做成可判断任意类型数据的动态数组,不知道这个函数的参数类型怎么写,或有其他什么办法来判读任意类型的动态数组是否为空 展开
想做个判断为空的函数,在函数内部用 Ubound判断数组长度,通过捕捉错误,判断数组是否为空,问题是想把这个函数做成可判断任意类型数据的动态数组,不知道这个函数的参数类型怎么写,或有其他什么办法来判读任意类型的动态数组是否为空 展开
1个回答
展开全部
刚刚找到一个好方法
Private Sub Command1_Click()
Dim a(), i As Long
MsgBox hasredim(a), 64, "Has a() been redimed?" '未初始化
ReDim a(20)
For i = 1 To 20
a(i) = Chr(i + 64)
Next
MsgBox hasredim(a), 64, "Has a() been redimed?" '初始化后
Erase a '释放空间后
MsgBox hasredim(a), 64, "Has a() been redimed?"
End Sub
Function hasredim(ByRef x()) As Boolean '定义布尔函数
Dim temp As String
temp = Join(x, ",")
hasredim = LenB(temp) > 0 '空数组长度为零
End Function
Private Sub Command1_Click()
Dim a(), i As Long
MsgBox hasredim(a), 64, "Has a() been redimed?" '未初始化
ReDim a(20)
For i = 1 To 20
a(i) = Chr(i + 64)
Next
MsgBox hasredim(a), 64, "Has a() been redimed?" '初始化后
Erase a '释放空间后
MsgBox hasredim(a), 64, "Has a() been redimed?"
End Sub
Function hasredim(ByRef x()) As Boolean '定义布尔函数
Dim temp As String
temp = Join(x, ",")
hasredim = LenB(temp) > 0 '空数组长度为零
End Function
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询