+ Reply to Thread
Results 1 to 4 of 4

Proper way to return empty object

  1. #1
    Registered User
    Join Date
    01-13-2020
    Location
    usa
    MS-Off Ver
    office 365
    Posts
    15

    Proper way to return empty object

    I have a function that returns an object. The object is always instantiated but could be empty (Dictionary). If it's empty I want to return something to the IF construct that says false.

    What is the proper way of recognizing a "failure" with functions that return objects?

    Thank you

  2. #2
    Registered User
    Join Date
    11-06-2012
    Location
    Texas
    MS-Off Ver
    O365
    Posts
    27

    Re: Proper way to return empty object

    If you know the dictionary exists and need to see if there's anything in it, check if .Count returns 0.

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Proper way to return empty object

    Quote Originally Posted by fatkatie View Post
    ... to return something to the IF construct that says false ...
    There are a few methods that will verify / set it up, you have one of them above, others are e.g.: IsArray (arr = dict.Keys => IsArray(arr)), IsEmpty(arr = dict.Keys => IsEmpty(arr)), etc., but what does your code look like ?

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Proper way to return empty object

    The following working example code may help you.
    Please Login or Register  to view this content.
    Lewis

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Formula to return empty string instead of null when column table is empty
    By jaryszek in forum Excel Formulas & Functions
    Replies: 26
    Last Post: 02-14-2020, 06:37 AM
  2. Return proper value from chart
    By kmlloyd in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-21-2016, 02:56 PM
  3. value return is not on proper header
    By darksquare in forum Excel General
    Replies: 3
    Last Post: 04-09-2016, 02:10 AM
  4. Find First proper empty row
    By Rob K in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2015, 08:09 AM
  5. [SOLVED] Proper way to return to beginning of sub?
    By smaier69 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-14-2013, 08:44 PM
  6. Function to return object reference given object name
    By 6StringJazzer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-28-2010, 09:07 PM
  7. Replies: 2
    Last Post: 03-31-2009, 03:55 PM

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