QuickBasic Debugging

This material came from pages on qbasic.phatcode.net, unfortunately they no longer appear to be available.

  • When debugging a program it is possible to pause execution, make changes to the code, and continue the program running and perform further debugging. In other words, there is no need to stop the debugger when one encounters an error.


  • Add Watch – Debug Menu -> Add Watch
    • “The Add Watch command displays the values or variables and expressions as the program executes.” (QB 18.1)
    • You’ll need to provide either the name of a variable or an expression to watch.
    • There are also Delete Watch and Delete All Watch options for removing watches.
  • Instant Watch – Shift + F9 – Debug -> Instant Watch – Move the cursor within or to the right of a variable or select an entire expression and choose instant watch from the debug menu.
    • “The Instant Watch command displays the value of the variable or expression containing the cursor in a dialog box–you do not need to open the Watch window.” (QB 17.3.3)
  • Watchpoint – Stops the program when a monitored value/expression becomes true (nonzero).
    • “A watchpoint is an expression that stops a program when the expression becomes true (nonzero).” (QB 17.3.2)
  • Watch Expression – Monitor the value of a variable as one moves through the code.
    • Debug –> Add Watch
    • “Watch expressions…let you observe the value of a variable (a number or text string) or the condition of an expression (true or false) in an executing program.” (QB 17.3.3)
  • Watch Window – Appears at the top of the screen during program execution.
    • “The Watch window is the window that opens at the top of the QuickBASIC screen to let you track watchpoint conditions or watched expressions during program execution.”
    • You have to add a watch for each part of the program in which one wants to monitor a variable/expression.
    • True = -1; False = 0

Tracing and History

  • Tracing – Turns on history and allows you to see the last twenty statements executed as well as the twenty statements about to be executed.
    • “The Trace On command highlights each statement as it executes. If the program manipulates the screen, QuickBASIC switches back and forth between the highlighted statements and the output screen (this is referred to as ‘animated execution’).” (QB 17.3.1)
  • Trace On – Debug -> Trace On – Highlights each statement as it executes.
    • “Steps through the program in slow motion, highlighting the currently executing statement…” (QB 18)
    • Normal Tracing – Run entire program at once.
    • Single Stepping – F8 – One statement at a time.
      • “By single stepping and using the Watch window together, you can gain a thorough understanding of how each statement affects your variables.” (QB 17.3.6)
    • Procedure Stepping – F10 – One procedure at a time.
      • “Executes a procedure call and the procedure as a single statement. If you are single stepping and encounter a procedure you know works properly, procedure stepping lets you execute the entire procedure at once…” (QB 17.3.6)
  • Breakpoint – F9 – Debug -> Toggle Breakpoints
    • “A breakpoint is a location in your program where you want execution to pause.” (QB 17.3.2)
    • There is also a Clear All Breakpoints option.
  • History On – Debug -> History On
    • “The History On command allows you to trace backward and forward through the last 20 statements executed by the program. This is particularly useful when you get a run-time error and you want to see which 20 statements were executed immediately preceding the error.” (QB 18.7)
    • History Back – Shift + F8 – Used to check the twenty last statements executed.
      • Interrupt program execution using CTRL+BREAK.
    • History Forward – Shift + F10 – Allows one to go forward through the History statements after one has gone backwards.


  • Break on Errors – Debug –> Break on Errors
    • “Break on Errors disables error handling and halts execution when an error occurs.” (QB 17.3.6)
  • Execute to Cursor – F7
    • “Executes from the beginning of a program up to and including the line containing the cursor, and then halts execution. Use this feature to quickly execute to a problem causing section of code, and then single step to find the error.” (QB 17.3.6)
  • Set Next Statement – Debug -> Set Next Statement
    • “Changes the execution sequence of an interrupted program so that the next statement to execute will be the one at the cursor.” (QB 17.3.6)
    • Can be used after fixing an error to tell QB to resume at the line
  • Immediate Window – Allows one to input code directly and execute it while debugging a program.
    • “The Immediate window is the window at the bottom of the screen. In it you can execute BASIC statements directly to gain information useful to debugging.” (QB 17.3.5)
    • Can only access code in the currently active module/procedure.
  • Output Screen – F4


  • The content originally included on this page was drawn from pages on qbasic.phatcode.net, unfortunately they no longer appear to be available.
  • Microsoft QuickBASIC: Learning to Use MS QuickBASIC 4.5. Microsoft, 1988.