Results 1 to 16 of 16

Thread: Compiled Debug Statments

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2014
    Posts
    553

    Compiled Debug Statments

    I had always thought that Debug statements were completely removed by the compiler when creating Executable files to be run outside of the IDE.

    Is this also true for ActiveX components?

    The reason I'm asking is that I was debugging a UserControl where in the 'Paint' event I have the following statement:

    Code:
         Debug.Print "Paint", UserControl.Extender.Index, time

    I was using the statement to track Control Array's Individual elements.

    I had forgotten about the Debug statement and in a new Project included the same UserControl / ActiveX. In this new project I wasn't using Control Array's and I got the following error:

    Name:  Debug_a.JPG
Views: 335
Size:  5.0 KB

    Mixed with this error

    Name:  Debug_b.JPG
Views: 316
Size:  4.6 KB

    Which was then followed by this error:

    Name:  Debug_03.JPG
Views: 338
Size:  11.4 KB


    I went back to the UserControl and removed the Debug.Print statement from the Paint Event, recompiled, registered and tried running the new project again, and It ran without error.

    Am I missing something in the compile process to completely remove Debug statements, or are they always left around?

    Thanks.
    Last edited by stuck-n-past; Oct 12th, 2017 at 04:12 PM.

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Compiled Debug Statments

    Debug.Print compiles as a method call.

    While the compiler might detect them and omit them, it is probably more effective and less work to just go ahead, evaluate the arguments, and have the method call do nothing when called in the normal runtime vs. the IDE runtime.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2014
    Posts
    553

    Re: Compiled Debug Statments

    That certainly appears to be what's happening as it's definitely executing code which is part of the Debug.Print statement. While it might not be outputting the text, it's still expending work as it processes the arguments.

    I have always made the assumption that there was no concern in leaving Debug statements in my code, thinking they were completely removed by the compiler. I'm going to have to rethink things where once assuming there was no performance impact by leaving them in place, but now knowing that's not the case.

    I'll be double checking to make sure all of my Debug statements are removed or commented out, which I usually do, but never placed much concern in doing so thinking it wasn't too important either way - Not so anymore!

  4. #4
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    380

    Re: Compiled Debug Statments

    Quote Originally Posted by stuck-n-past View Post
    I have always made the assumption that there was no concern in leaving Debug statements in my code, thinking they were completely removed by the compiler. I'm going to have to rethink things where once assuming there was no performance impact by leaving them in place, but now knowing that's not the case.
    You do have to be wary when calling Debug.Print but you don't have to worry when using Debug.Assert.

    Quote Originally Posted by MSDN
    Note When you compile your application into an .exe file, Debug.Print statements are removed. Thus, if your application only uses Debug.Print statements with strings or simple variable types as arguments, it will not have any Debug.Print statements. However, Visual Basic will not strip out function calls appearing as arguments to Debug.Print. Thus, any side-effects of those functions will continue to happen in a compiled .exe file, even though the function results are not printed. Read more...
    Quote Originally Posted by MSDN
    A Debug.Assert statement will never appear in a compiled application, but when you're running in the design environment it causes the application to enter break mode with the line containing the statement highlighted (assuming that the expression evaluates to False). Read more...


    Quote Originally Posted by stuck-n-past View Post
    I'll be double checking to make sure all of my Debug statements are removed or commented out, which I usually do, but never placed much concern in doing so thinking it wasn't too important either way - Not so anymore!
    Quote Originally Posted by MSDN
    If you do not want debugging statements included in the application you distribute to users, use conditional compilation to conveniently delete these statements when the Make EXE File command is used. Read more...

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2014
    Posts
    553

    Re: Compiled Debug Statments

    Victor - Thank you very much for the Debug information.

    I must apologize for posting such a question about Debug information when obviously it's all available on MSDN. While it might sound hard to believe, I do try searching for answers before posting questions here. I can't begin to tell you the amount of time I spend checking the Web. And that doesn't include the endless hours wasted getting sidetracked when other, not so relevant, VB information pops up. Don't even get me started when a search, heaven forbid, leads me to a YouTube link. I can get sucked into one video after another, and before I know it, my browser begins to slow from all of the open tabs.

    I feel bad in asking a questions on the Forum, only to have others point out that the answers are out there for all to find and read. Clearly I suck at online research!

    Thanks again for the info.

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Compiled Debug Statments

    Clearly I suck at online research!
    Google-Fu needs some work grasshopper.

    Tip: more times than not, this is my favorite google search string: msdn vb6 [add function here]
    Example: msdn vb6 debug.print. That link was 8th hit in my search, but typically I get the desired hits higher up in the list
    Last edited by LaVolpe; Oct 13th, 2017 at 09:09 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: Compiled Debug Statments

    You should only feel bad if you didn't bother trying, otherwise the forum is perfect for when you can't find (or don't know how to search for) the answer.

  8. #8
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,719

    Re: Compiled Debug Statments

    Quote Originally Posted by stuck-n-past View Post
    Victor - Thank you very much for the Debug information.

    I must apologize for posting such a question about Debug information when obviously it's all available on MSDN. While it might sound hard to believe, I do try searching for answers before posting questions here. I can't begin to tell you the amount of time I spend checking the Web. And that doesn't include the endless hours wasted getting sidetracked when other, not so relevant, VB information pops up. Don't even get me started when a search, heaven forbid, leads me to a YouTube link. I can get sucked into one video after another, and before I know it, my browser begins to slow from all of the open tabs.

    I feel bad in asking a questions on the Forum, only to have others point out that the answers are out there for all to find and read. Clearly I suck at online research!

    Thanks again for the info.
    You're one step away from being me... I'll spend hours stuck on a problem, searching the web, digging through code samples, trying 1000 different things, then finally giving up and posting the question here... only to then immediately realize what was wrong and get it working

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2014
    Posts
    553

    Re: Compiled Debug Statments

    fafalone - Right there with ya! I so hate it because I feel as I'm using the Forum when I should be able to find the problem myself and shouldn't be bothering other members. And I can't say enough about my internet nemesis YouTube, which has some mystical hypnotic power over me, drawing me in and never letting go.

  10. #10
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    Re: Compiled Debug Statments

    We've all been there... there's been times that I don't see the answer until I'm clicking that "Create thread" button... I liken it to talking to someone in the office... sometimes that's all you need, is the chance to explain it, for your mind to work it out and see the answer that's right there. There are way more times I get half way through a post when I realize "duh... that's the answer right there...." and end up deleting the post than I do actually posting the post. Sometimes it's only post post posting that I see what's in front of me.

    I believe it's known as the Rubber Duck Scenario.

    -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??? *

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2014
    Posts
    553

    Re: Compiled Debug Statments

    tg - I'd of never admitted it til now, but I too have positioned the mouse over the submit button ready to start a new thread only to stop a rethink things. Then after rereading my own words, I've scrapped the whole thing and heading back to my code.

    Have to tell ya, never heard of the Rubber Duck Scenario before and how ironic, instead of asking what it meant I went searching for it.


    The phrase refers to the fact that the very act of explaining the problem to someone reveals the solution without them having to say anything. So you could have explained the problem to anyone or anything, including a rubber duck.

    That's one to remember.


    One of the problems I've had in the past trying to research a problem is not knowing the proper terminology for the issue I'm dealing with. Sort of stops one dead in your tracks.

  12. #12
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    Re: Compiled Debug Statments

    Quote Originally Posted by stuck-n-past View Post
    One of the problems I've had in the past trying to research a problem is not knowing the proper terminology for the issue I'm dealing with. Sort of stops one dead in your tracks.
    That's a problem I've had in the past too... and one I'm certain a lot of noob developers have as well, which is why they come here looking for help with some of the basic questions - we've gotten ourselves conditioned to know the keywords to pick out and search with... the basic new developer likely isn't going to know how to do that. Doubly so given what I hear around here about some profs they have.

    -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??? *

  13. #13
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    868

    Re: Compiled Debug Statments

    Quote Originally Posted by stuck-n-past View Post
    That's one to remember.
    Indeed

  14. #14
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Compiled Debug Statments

    Quote Originally Posted by stuck-n-past View Post
    ...And I can't say enough about my internet nemesis YouTube, which has some mystical hypnotic power over me, drawing me in and never letting go.
    lol, I tried to snag you, in post #6, by linking youtube in my reply. Sounds like you didn't take the bait
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2014
    Posts
    553

    Re: Compiled Debug Statments

    Your a monster Lavolpe - lol!

    I totally fell for the bait, hook-line and sinker! I was just too damn embarrassed to admit I followed the link and more .

    I couldn't for the life of me understand why you included that particular video, so I chalked it up to programmer dementia and never would have brought the subject up. Now I know the devil's in the details, or in this case, in the YouTube links.

  16. #16
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Compiled Debug Statments

    Quote Originally Posted by stuck-n-past View Post
    I couldn't for the life of me understand why you included that particular video, so I chalked it up to programmer dementia
    Just so you don't think it's dementia. I used the term "google-fu" in that post, which has its origin from "kung-fu". The popular U.S. TV series Kung-Fu leading character was known as grasshopper in his youth. Tip: The link above is not youtube
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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