How can i figure out if an array ist initialized or not.
dim array() as string
' this doesn't work
if isempty(array) then messagebox "Empty"
if isnull(array) then messagebox "NULL"
How can i figure out if an array ist initialized or not.
dim array() as string
' this doesn't work
if isempty(array) then messagebox "Empty"
if isnull(array) then messagebox "NULL"
Subject: uninitialized dynamic array
Find the error number, print the err code in the error trapping segment
then trap for the specific error
On error NNNN goto BLANKARRAY
BLANKARRY
Set the flag array empty
resume NEXT| or where ever
Subject: uninitialized dynamic array
Hi,
use the following concept:
On Error Goto errh
Dim arr() As String
x = Ubound( arr ) 'here error occuries if arr() is NOT initialized
If Isempty( arr() ) Then
Msgbox "empty"
End If
If Isnull( arr() ) Then
Msgbox "null"
End If
Exit Sub
errh:
Print Error$ & { } & Erl ' or your code
Exit Sub
Subject: RE: uninitialized dynamic array
so, this ‘workaround’ by using an errorhandler is the only way?i’ve hoped there’s an implemented function to check the array’s initialization status.
thanks for help ![]()
Subject: RE: uninitialized dynamic array
Using an error handler is your best option. An attempt to use an unitialized dynamic array will return error number 200, and knowing that should allow you to write a handler to gracefully recover from the error.
Subject: RE: uninitialized dynamic array
I don’t think there is.
Another workaround is to declare array as a variant at first.
Dim array As Variant
Msgbox Isarray(array) 'false
If Isarray(array) = False Then
Redim array(5) As String
array(0) = "Hello world"
End If
Msgbox Isarray(array) 'true
Subject: RE: uninitialized dynamic array
What I always do if I know I might need to check the status is to redim the array immediately to 0, then when checking just check for a blank string