Results 1 to 4 of 4

Thread: VB6 Equivalent of C #ifdef directives

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2012
    Posts
    433

    VB6 Equivalent of C #ifdef directives

    I want to add codes for debug log using some directives.
    What is the VB6 equivalent of C-language's #ifdef directives?

    Here is the C code and I want to know VB6 directive.
    ------
    #define DEBUGLOG
    #ifdef DEBUGLOG
    //Do Something
    #endif
    ------

  2. #2
    Hyperactive Member
    Join Date
    Jun 2011
    Posts
    461

    Re: VB6 Equivalent of C #ifdef directives

    VB Code:
    1. #Const Test = True
    2. #If Test Then
    3. '...
    4. #Else
    5. '...
    6. #End If
    Last edited by MikiSoft; Jun 21st, 2015 at 05:15 AM. Reason: Boonie West corrected me.

  3. #3
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: VB6 Equivalent of C #ifdef directives

    Quote Originally Posted by MikiSoft View Post
    Code:
    #Const Test As Boolean = True
    The #Const directive doesn't allow the data type clause.

    Quote Originally Posted by jdy0803 View Post
    ... I want to know VB6 directive.
    The VB6 manual discusses them here.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  4. #4
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    813

    Re: VB6 Equivalent of C #ifdef directives

    I would argue that conditional compilation is great for optional (paid) features that you don't want to include in the shipped executable until someone coughs up the money for them.

    Personally, I'd suggest that you should have your debug logging switchable at run-time, not compile-time.
    When your customer has one of those really "odd" problems (i.e. one of the the 99.9% of problems; the ones that only happen out there, in The Wild), then shipping them a new executable to install, just to find out what the trouble might be, probably isn't your best option. Having something that they can just "switch on" when required (possibly through a one-time or time-limited passcode) shows them that you are pro-active in sorting out their problems (i.e. you actually thought about all this before shipping the product) and it gets you the diagnostic information that you require more reliably and in a more timely fashion (so you can fix the issue more quickly; another "plus" with customers).

    Regards, Phill W.

Posting Permissions

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



Click Here to Expand Forum to Full Width