locked
How to debug a single routine (not all app) in Visual Studio 2017 Community RRS feed

  • Question

  • Hi,

    I'm sorry asking such a trivial question, but I'm new in Visual Studio.

    I can't succed in doing something very easy that I was doing zillion of time in  the VBA editor of office.

    IF I have a very trivial routine such, i.e.

    Public Sub Gretings()
        msgbox("Hello Frank!")
    end Sub

    in one of my modules and I would to lunch and inspect it [maybe not exactly that one :-) ] how should I do?

    Just this portion of code not the whole application.

    In VBE Editor you just put the cursor inside the Sub and you hit run. I can't believe I need all the long stuff I founded on the net about Test Unit Code o IntelliTest...

    Thanks, Lauro
    Monday, January 15, 2018 12:22 PM

Answers

  • In VBE Editor you just put the cursor inside the Sub and you hit run.

    This was not debugging. This was just a "comfort" function to execute macros directly. Any Public Sub in VBA (Office) is an executable macro. Thus this functionality.

    VS and your used project type are a completely different environment. So you need to set a break point and the run your program in debugging mode in VS. Then VS will halt at this point.

    See also Debugger Basics.

    • Proposed as answer by Fletch Zhou Wednesday, January 17, 2018 2:29 AM
    • Marked as answer by Lauro2 Thursday, January 18, 2018 9:35 PM
    Monday, January 15, 2018 12:26 PM

All replies

  • In VBE Editor you just put the cursor inside the Sub and you hit run.

    This was not debugging. This was just a "comfort" function to execute macros directly. Any Public Sub in VBA (Office) is an executable macro. Thus this functionality.

    VS and your used project type are a completely different environment. So you need to set a break point and the run your program in debugging mode in VS. Then VS will halt at this point.

    See also Debugger Basics.

    • Proposed as answer by Fletch Zhou Wednesday, January 17, 2018 2:29 AM
    • Marked as answer by Lauro2 Thursday, January 18, 2018 9:35 PM
    Monday, January 15, 2018 12:26 PM
  • Thanks you for the answer.

    Lauro

    Thursday, January 18, 2018 9:36 PM