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 7773445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:08:11+00:00 2026-06-01T17:08:11+00:00

My code is as follows: #Const debuggingEnabled = False Sub debugMessage(str As String) #If

  • 0

My code is as follows:

#Const debuggingEnabled = False

Sub debugMessage(str As String)
    #If debuggingEnabled Then
        Debug.Print str
    #End If
End Sub

Sub doThings()
    debugMessage "test"   'Does this get optimised away, or must it be explicitly
                          'wrapped with `#If .. #End If` every time it's called
                          'if one is to avoid the jump and stack push/pop ops?
End Sub

Does Microsoft’s VBA compiler optimise away calls to procedures that do nothing? How can I find out?

  • 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-01T17:08:11+00:00Added an answer on June 1, 2026 at 5:08 pm

    Upgrading this from comment to answer:

    What is the point in “optimizing away” a procedure containing a single, one-bit, binary, boolean test? Are you sure that this represents a significant portion of execution time? The chances of that are pretty remote.

    Before optimizing, always do some profiling, so you don’t waste time and worry on bits of code that represent 0.0001% of your execution time.

    VBA has no native profiler, but there are third-party options out there, some of them free. This is one, accompanied by an instructive read: Profiling and Optimizing VBA
    By bruce mcpherson
    . A DuckDuckGo search gives plenty of other leads as well.

    So, the answer to your original question is: I don’t think VBA optimizes such a procedure away, but I’m not entirely sure, and either way it is in all likelihood completely irrelevant. Before worrying about optimizing, always do some profiling, so you can spend your time wisely. After profiling, you will almost always find that what you thought slowed down your program is actually very fast, and that something else is the culprit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, I have some code as follows template<typename Type> Type* getValue(std::string name, bool tryUseGetter
The code under test follows. view.QueryResultsGrid is a System.Windows.Forms.DataGridView object: public void SelectCheckedChanged(object sender,
I have some code defined as follows: typedef long (*ShellExecFunct)(long, const char*, const char*,
The code in c++ is as follows: #include<iostream> #include<string> #include<set> using namespace std; class
Why can't I do something like this in c# (pseudo code follows) Interface1 {
I'm using this plugin: http://www.jeremymartin.name/projects.php?project=kwicks And my code follows this example: http://www.jeremymartin.name/examples/kwicks.php?example=7 I'm using
I have code as follows: $(#item_select).change(function() { var params = $(#item_select option:selected).val(); $.post('/account/ar_form.php', {idata:
For some code as follows, opts, args = getopt.getopt(sys.argv[1:], c:, ... for o,v in
I have a piece of javascript code as follows: var data = { ...
I have 3 different jquery uses & put it into one code as follows:

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.