Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8188529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:56:49+00:00 2026-06-07T02:56:49+00:00

For a custom object, I want to test two conditions. The first is whether

  • 0

For a custom object, I want to test two conditions. The first is whether the object is nothing. If so, enter the block. If the object is not nothing, I want to do a test on one of the object’s properties, and only enter the block if it passes this test.

So the statement would by akin to:

If myObject Is Nothing Or myObject.myInt > x Then
    'Perform my task
End If

If myObject is in fact nothing, this throws an error, since when it tests the second condition, it tries to access a property of an object that isn’t there.

Most languages I’ve worked with in the past would not bother to test the second condition of an Or statement if it found the first condition to be true, so you could get away with writing the line above. VBA doesn’t seem to allow this. Is there any equivalent way i could write this statement, without resorting to:

If myObject Is Nothing Then
    'Perform my task
ElseIf myObject.myInt > x Then
    'Perform my task
End If

?

EDITED FOR CLARITY

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:56:50+00:00Added an answer on June 7, 2026 at 2:56 am

    You could create a flag:

    PerformTheTask = False
    
    If myObject Is Nothing Then
        PerformTheTask = True
    ElseIf myObject.myInt > x Then
        PerformTheTask = True
    End If
    
    If PerformTheTask Then
        'Perform my task
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom principal object that I want to be able to serialize
I have a QPushButton, QDateEdit and another custom object. I want to connect the
Is there an easy way to test whether an object is a immutable (numbers,
1) I have created a custom object Hello . Added two lookup fields to
I want to implement custom JSP list tag, but have problem with accessing properties
My question is about how to sort an ArrayList with custom Object by one
I want to show my custom objects (images, formulas) in UITableView row name. Is
I have an array of custom objects. MyCustomArr[]. I want to convert this to
I have a listView with custom objects defined by the xml-layout below. I want
I want to create a custom set that will automatically convert objects into a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.