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()?

Private Sub Form_Load()
    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/
Before you buy.



Fri, 01 Nov 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. CopyMemory and Variant Array question

2. Array to Variant and Variant to array problem

3. array of variants vs. a variant array for marshalling

4. Variant array vs. array of variant.

5. Coercing A Variant Array of Variants into an integer array.

6. Variant Array --> ByteArray() --> Variant Array

7. Array of Boolean as Variant ?

8. variant containing an array

9. VB6 Variant Arrays in DOTNET C#/VB

10. Variant Arrays

11. Passing variant containing byte array

12. Trying to pass a Variant Array of Doubles to ActiveX from HTML

 

 
Powered by phpBB® Forum Software