Private Sub Command1_Click()
Dim a() As String, 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 String) As Boolean '定义布尔函数
Dim temp As String
temp = Join(x, ",")
hasredim = LenB(temp) > 0 '空数组长度为零
End Function
……