Testing to see if an array has been initialised

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ray

    Testing to see if an array has been initialised

    Here's the code example...

    Dim myArray() as string

    later I will redim the array in a for/next or a Do/While Loop

    x = ubound(myArray) +1 <<< causes error 9 if no elements exist
    already!
    redim Preserve myArray(x)

    Here's the question... how do I test the array to see if it was already
    initialised without trapping Error 9 (array not initialised)?
    I have tried IsArray(myArray ) and that returns TRUE and I have tried a whole
    bunch of others IsEmpty etc etc

    Any help appreciated

    Ray


  • Rick Rothstein

    #2
    Re: Testing to see if an array has been initialised

    I just posted answer to this same question in another newsgroup. Please
    consider the following...

    From a post by Jeff Johnson:

    "You have posted this question individually to multiple groups. This is
    called Multiposting and it's BAD. Replies made in one group will not be
    visible in the other groups, which may cause multiple people to respond to
    your question with the same answer because they didn't know someone else had
    already done it. This is a waste of time.

    If you MUST post your message to multiple groups, post a single message and
    select all the groups (or type their names manually, separated by commas) in
    which you want it to be seen. This is called Crossposting and when used
    properly it is GOOD."

    Rick - MVP


    "Ray" <newsNOSPAM@qui tealright.com> wrote in message
    news:HlM%b.4878 $rb.62614@news. indigo.ie...[color=blue]
    > Here's the code example...
    >
    > Dim myArray() as string
    >
    > later I will redim the array in a for/next or a Do/While Loop
    >
    > x = ubound(myArray) +1 <<< causes error 9 if no elements exist
    > already!
    > redim Preserve myArray(x)
    >
    > Here's the question... how do I test the array to see if it was already
    > initialised without trapping Error 9 (array not initialised)?
    > I have tried IsArray(myArray ) and that returns TRUE and I have tried a[/color]
    whole[color=blue]
    > bunch of others IsEmpty etc etc
    >
    > Any help appreciated
    >
    > Ray
    >
    >[/color]


    Comment

    Working...