CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2012
    Posts
    1

    How to comment on a line at runtime

    Is there a way one can comment on a line of code at runtime. I want the line to be skipped at some at some points in the program, when certain conditions are met.
    Thank you.

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: How to comment on a line at runtime

    Hmmm... Isn't that what an If statement is for?
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: How to comment on a line at runtime

    You can't comment a line during run time. You are speaking of conditions, well, as Eri523 said, you need to use an If Statement. Otherwise you should look into debugging which provides tools such as Step Over (which skips some lines of code ) and Step Into ( which goes to the next line(s) ).

    If you provide more details on what you want to achieve, we coulkd help better

  4. #4
    Join Date
    Nov 2006
    Location
    Staffordshire, England
    Posts
    12

    Re: How to comment on a line at runtime

    Quote Originally Posted by Ucheske View Post
    Is there a way one can comment on a line of code at runtime. I want the line to be skipped at some at some points in the program, when certain conditions are met.
    I'm sure you comment a line so as to skip it if certain conditions aren't met but thats what If Then is for.

    You could put a BreakPoint in the code so when your apps gets to that line of code it will stop. You can look at the code window and move through the code by pressing the F8 button that will slip through a line at a time. You can look at the code window and hold your mouse over any variable and if will show its value.
    I've been programming with VB for 17 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

    Martin2k

  5. #5
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How to comment on a line at runtime

    No you can not comment a line of code at runtime, and no you can not make a comment do anything other than display a comment in the editor. Comments are completely ignored at run time and do not exist in the exe.

    As stated by others this is what the If Then is for.

    Comments are simply used to make the code easier to understand.

    And if you actually meant to say Comment out a line at runtime then no you can not do that either.
    Last edited by DataMiser; June 27th, 2012 at 11:29 AM.
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to comment on a line at runtime

    That's what Debug.Print does. Prints to the output window ONLY when you run in DEBUG mode.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How to comment on a line at runtime

    I'm not sure what debug.print would have to do with it ?
    Always use [code][/code] tags when posting code.

  8. #8
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How to comment on a line at runtime

    tells you WHICH variable to monitor at various stages of your application
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  9. #9
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: How to comment on a line at runtime

    I figured out what you were referring to after I posted, I just did not think that is what the OP was referring to. Seems like the intent was to either add a comment to the code at runtime or more likely change a line of code into a comment so it does not execute neither of which are possible.

    As others had said it appears that what is need is a IF Then block
    Always use [code][/code] tags when posting code.

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

Featured