Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Declare Function GetMem4 Lib "msvbvm60" (ByVal pSrc As Long, ByVal pDst As Long) As Long
- Public Declare Function ArrPtr Lib "msvbvm60" Alias "VarPtr" (arr() As Any) As Long
- Public Function ArrayExists(ByVal ppArray As Long) As Long
- GetMem4 ppArray, VarPtr(ArrayExists)
- End Function
- ? ArrayExists(ArrPtr(someArray))
- Public Function IsArrayInitialized(arr) As Boolean
- Dim rv As Long
- On Error Resume Next
- rv = UBound(arr)
- IsArrayInitialized = (Err.Number = 0)
- End Function
- Dim arr() As String
- arr = Split(vbNullString, ",")
- Debug.Print UBound(arr)
- Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
- (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
- Public Function ArrayIsInitialized(arr) As Boolean
- Dim memVal As Long
- CopyMemory memVal, ByVal VarPtr(arr) + 8, ByVal 4 'get pointer to array
- CopyMemory memVal, ByVal memVal, ByVal 4 'see if it points to an address...
- ArrayIsInitialized = (memVal <> 0) '...if it does, array is intialized
- End Function
- Dim someArray() As Integer
- If ((Not someArray) = -1) Then
- Debug.Print "this array is NOT initialized"
- End If
- Dim ArrayToTest() As String
- MsgBox StringArrayCheck(ArrayToTest) ' returns "false"
- ReDim ArrayToTest(1 To 10)
- MsgBox StringArrayCheck(ArrayToTest) ' returns "true"
- ReDim ArrayToTest(0 To 0)
- MsgBox StringArrayCheck(ArrayToTest) ' returns "false"
- Dim x As String
- x = Join(o)
- StringArrayCheck = (Len(x) <> 0)
- Dim someArray() as Integer
- If someArray Is Nothing Then
- Debug.print "this array is not initialised"
- End If
Add Comment
Please, Sign In to add comment