Results 1 to 3 of 3

Thread: Dynamic Array Checking

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Dunmow,Essex,England
    Posts
    898

    Post

    I have a variant dynamic array declared;

    private vntArray() as variant

    How can I test if it has been dimensioned.

    Everything I try always gives me back <subscript out of range>. I could check in the error handler for this, but this is messy and not a nice way to do it.

    Regards
    Bill

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    well first, the only way it will be dimensioned is if you do it. What you could do, set a public boolean, setting it to false when prog starts. Then whereever you dimension it, set it to true. Then where ever you try to use it, check to make sure the boolean is true. It's not very elegant but it would work.

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    It's better to try to avoid using global variables. Here is code that will do what you want.
    Code:
        On Error Resume Next
        vntArray(0) = vntArray(0)
        If Err = 0 Then
            MsgBox "I'm dimensioned"
        Else
            MsgBox "I'm not"
        End If

    ------------------
    Marty
    HASTE CUISINE
    Fast French food.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width