Comments/Remarks and Program Compiling

Posted on 2005-04-11
Last Modified: 2010-05-02
Simple question (I would believe!):

Anything in a VB program that has an apostrophe in front of it is "greened out" as a remark or comment. Now, does that remark/comment compile into the final product? If it does, is there a way to prevent that from occuring without removing them all manually?

Thanks for the answer! Any evidence would be appreciated.
Question by:doinVBstuff
    LVL 5

    Expert Comment

    They shouldnt be compiled. It would be pretty silly to add stuff into the compiled program that wont be read by any person or even by the computer, it would take up Unnesessary space.

    LVL 9

    Accepted Solution

    No. you can test this out by opening a blank project and then boudle click on the form to open the code window. Under the Form_Load event type the following

    '' This is evidence that comments do not get compiled into the executable.
    '' So even though you comment your code no one other than those with your
    '' source can read them.
    '' Also variable names are not saved. IE If you have Dim Counter as long
    '' some one trying to reverse compile your program will not be able to see
    '' the Word Counter. VB replaces it with a generic name

    Compile the program. you can then open the program in notepad and see the comments are not compiled.
    LVL 44

    Expert Comment

    Just to make it unanimous, COMMENTS (' This would be a comment) are NOT compiled into the EXE


    Author Comment

    Ok, so that I get this straight, they are not compiled into the program. So, it begs to ask the question, are they actually removed or just hidden? The reason I ask is because I noticed that with one of my larger programs, if I remove the comments, it seems to make the compiled program smaller in actual size. Is this just coincidental or something more?

    Thanks for all the answers so far.
    LVL 9

    Expert Comment

    Just coincidental. You may have removed more than just comments. maybe a component reference or a variable declaration that was not used. The variable names and comments are not compiled into the program on VB6. Are you using VB6 or something else?
    LVL 5

    Expert Comment

    comments are totally ignored by the compiler, so when the exe is created the compiler hasnt readthe comments to put them into the exe.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now