Variant Array Question
Author Message
Variant Array Question

If you dimension an array

Dim vArray()

and never redim it can you detect the fact that it has no
elements with out having to do a ubound and trapping the error?

C.David Johnson
Missionary searching for my appointed field
http://www.*-*-*.com/

Sun, 27 Oct 2002 03:00:00 GMT
Variant Array Question

Quote:

> If you dimension an array

> Dim vArray()

> and never redim it can you detect the fact that it has no
> elements with out having to do a ubound and trapping the error?

> C.David Johnson
> Missionary searching for my appointed field
>         http://www.siteblock.net

How about initially dimming it with 1 element? Then UBound will return 0 and
you can take this as an indication that the array has not been redimmed.

Peter G. Aitken

Sun, 27 Oct 2002 03:00:00 GMT
Variant Array Question

Quote:

> > If you dimension an array

> > Dim vArray()

> > and never redim it can you detect the fact that it has no
> > elements with out having to do a ubound and trapping the error?

> > C.David Johnson
> > Missionary searching for my appointed field
> >         http://www.siteblock.net

> How about initially dimming it with 1 element? Then UBound will
return 0 and
> you can take this as an indication that the array has not been
redimmed.

> Peter G. Aitken

How about diming it as variant and then checking IsArray()?

Dim varArray As Variant, strMsg As String

If Not IsArray(varArray) Then ReDim varArray(0)
varArray(0) = "Test"

strMsg = "There are no elements in the array"
If IsArray(varArray) Then strMsg = "There are elements in the array"
MsgBox strMsg, vbOKOnly + vbInformation, "Are there elements in the
array?"
End Sub

Dror

Sent via Deja.com http://www.deja.com/

Fri, 01 Nov 2002 03:00:00 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages