+ Reply to Thread
Results 1 to 3 of 3

'#define' equivalent in VBA?

  1. #1
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Question '#define' equivalent in VBA?

    Does VBA support an equivalent to C's "#define" for inline replacement?

    For example I have a section of code, where a tollerance is allowed, and the tollerance could be either a fixed tollerance or a percentage tollerance, that I would like to be able to change at a later date:

    Please Login or Register  to view this content.
    Then at the top of the file I could have:
    Please Login or Register  to view this content.
    Which would cause the line in the original code to be evaluated as:
    Please Login or Register  to view this content.
    Alternatively I could have at the top of the file:
    Please Login or Register  to view this content.
    Which would cause the line in the original code to be evaluated as:
    Please Login or Register  to view this content.
    Is something like this possible with VBA?
    Otherwise I can only see doing it with booleans and a 'value' parameter, so requiring code something like this:

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    Then a 'main' code of:

    Please Login or Register  to view this content.
    but as I have several of these tollerances for different things, and each one is in multiple places in the file the first method would be tidier and easier to up-keep..... if it is possible?

    Thanks
    Last edited by Phil_V; 05-08-2009 at 07:22 AM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: '#define' equivalent in VBA?

    No #Define equivalent.

    VBA as # conditional complilation syntax but that would still require you to test a condition in order to add or multiple the value of TOLLERANCE

    Please Login or Register  to view this content.
    In order to set the condition of TOLLERANCE_IS_FIXED you would need to display the VBA project dialog.
    In VBE use menu Tools > [I]projectname[I] properties...
    Conditional complication arguments.

    TOLLERANCE_IS_FIXED = 1
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: '#define' equivalent in VBA?

    Cheers for the reply Andy. That's a shame to hear that there is no equivalent, I guess I'll be doing it with IF statements (of one sort or another) after all then

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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