Results 1 to 6 of 6

Thread: #If DEBUG Then - What is it?

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    #If DEBUG Then - What is it?

    Code:
    #If DEBUG Then
            LogMessage("Did first thing")
    #End If
    What is it? how to use that? what are the advatages of using it ?
    Kanna

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: #If DEBUG Then - What is it?

    it's called a compiler directive... it's a way of telling the compiler, "Hey, only run this stuff if the DEBUG flag has been set." ... that way it only runs while in debug mode, but doesn't run in the compiled code.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: #If DEBUG Then - What is it?

    Quote Originally Posted by techgnome View Post
    it's called a compiler directive... it's a way of telling the compiler, "Hey, only run this stuff if the DEBUG flag has been set." ... that way it only runs while in debug mode, but doesn't run in the compiled code.

    -tg
    I didn't know that
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  4. #4
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: #If DEBUG Then - What is it?

    Debug is used as a development tool to view the values of you variables
    eg:
    Dim sName as string
    sName = "Sally"
    Debug.Print sName Looking in the immediate window will show Sally
    or Debug.Print App.Path will show the path you are working on
    many, many uses
    Very handy tool
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  5. #5
    Hyperactive Member su ki's Avatar
    Join Date
    Oct 2007
    Posts
    354

    Re: #If DEBUG Then - What is it?

    hey csKanna

    #if is the compiler directive means it directs compiler to do some conditional tasks
    following is the simple example just create an standard empty project and place a command button and then paste following in code window
    you will only get one messagebox because you have not DEBUGGING set

    vb Code:
    1. Private Sub Command1_Click()
    2.     #If DEBUGGING Then
    3.         MsgBox "hello this is show when DEBUGGING is set"
    4.     #End If
    5.    
    6.     MsgBox "This will be shown always"
    7. End Sub


    after checking once just go to properties of project and under make tab u will find last text box named conditional compilation arguments and paste there the following statement
    DEBUGGING = 1
    and then run the project again and click on button then will see the actual difference

    NOTE : Debug is predefined object as @isnoend07 said so it can't be used for conditional compilation

    hope this description will help you :-)
    * If my post helped you, please Rate it
    * If your problem is solved please also mark the thread resolved it is there in right top of page under thread tools
    * Why Rating is useful

  6. #6
    Addicted Member
    Join Date
    Oct 2008
    Posts
    195

    Re: #If DEBUG Then - What is it?

    I'm also curious. I know there are two predefined precompilation constants, i. e. Win16 and Win32. You can write code like

    #If Win32 then
    ...
    #End If

    if you want that your code would compile only under Win32. I think these are the only predefined precompilation constants in VB6. However, according to MSDN http://msdn.microsoft.com/en-us/library/swfss70d.aspx, there should also be other predefined constants. Do you think VB6 implements them? I tried, but those constants don't get capitalized as you type them, unlike Win16 and Win32, so I would guess they're not implemented. What do you think?

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