+ Reply to Thread
Results 1 to 6 of 6

Compile-time error- Wrong Number of Arguments when using isEmpty() on array elements

  1. #1
    Registered User
    Join Date
    08-22-2011
    Location
    NY, NY
    MS-Off Ver
    Excel 2003
    Posts
    10

    Compile-time error- Wrong Number of Arguments when using isEmpty() on array elements

    Hi,

    I am extremely confused why the following works in a normal VBA module:
    Please Login or Register  to view this content.
    But the exact same code does NOT work in a custom VBA Class, which has a Variant array as one of its private fields.

    In my custom class, I have (outside of any methods) the following array code:
    Please Login or Register  to view this content.
    In my class_intialize method, I redim() the array to have 3 elements, as follows:
    Please Login or Register  to view this content.
    Then, I have a function that calculates the number of elements in the array arr():
    Please Login or Register  to view this content.
    I cannot compile or run any code because I get a Compile Error: Wrong number of arguments or invalid property assignment. The text isEmpty is highlighted.

    I know of no other way of truly counting non-empty array elements. Worksheet function CountA counts all (including empty elements) and Worksheet function Count() does NOT count string elements, which is really unfortunate.

    Do I need to change how my custom class initializes the array or something? I have spent hours on this and I am completely out of ideas.
    Can anyone offer any advice? Thanks!
    Last edited by drinkmorecrabjuice; 08-22-2011 at 05:28 PM. Reason: clarity

  2. #2
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Compile-time error- Wrong Number of Arguments when using isEmpty() on array eleme

    Welcome to the forum.

    Please can you edit your post and surround your code snippets with code tags? (see my signature to see how).

    Once that's done, can you tell us if, in your project containing the custom class, if you go to tools > references, are there any references marked with the prefix "MISSING"?
    Hope that helps,

    Colin

    RAD Excel Blog

  3. #3
    Registered User
    Join Date
    08-22-2011
    Location
    NY, NY
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Compile-time error- Wrong Number of Arguments when using isEmpty() on array eleme

    Sorry about that. Done and done.

    No, there are no Available References (either checked or unchecked) with the prefix "MISSING".

  4. #4
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Compile-time error- Wrong Number of Arguments when using isEmpty() on array eleme

    Do you have a custom function or object called isEmpty in your project?

    I think a quick way to test this would be to add a VBA. prefix to your Length method.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-22-2011
    Location
    NY, NY
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: Compile-time error- Wrong Number of Arguments when using isEmpty() on array eleme

    SWEET! IT COMPILED! Oh my gosh, thank you. Just adding the "VBA." prefix worked. And actually, yes, deep inside my code I did have a custom isEmpty method. Silly me.

  6. #6
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: Compile-time error- Wrong Number of Arguments when using isEmpty() on array eleme

    Glad you got it sorted.... I reckon you should give that custom isEmpty method a different name.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1