Microsoft KB Archive/61340

= Watchpoints Set at Module Level Won't Break in a SUBprogram =

Article ID: 61340

Article Last Modified on 11/21/2006



This article was previously published under Q61340



SUMMARY
Watchpoints put on variables (which are set in QuickBasic's Debug menu) have a local scope. That is, you must reset the watchpoint on a variable in each SUBprogram or FUNCTION, even if the variable is in a SHARED or COMMON SHARED statement. This is by design.

If you add a watchpoint in the module-level code of a shared variable, and a SUBprogram or FUNCTION changes the variable so the watchpoint should break, the program will not break until the SUBprogram or FUNCTION returns to the module-level code.

This information applies to the QB.EXE environment in QuickBasic versions 4.00, 4.00b, and 4.50, and to the QBX.EXE environment of Microsoft Basic Professional Development System (PDS) version 7.00.



MORE INFORMATION
The following program, when run in the QuickBasic or QuickBasic Extended environment, demonstrates that watchpoints are local: DECLARE SUB test COMMON SHARED a  a = 0 CALL test PRINT &quot;After call&quot; END

SUB test a = 3 PRINT &quot;in sub - does not break&quot; END SUB To demonstrate this, set a watchpoint on &quot;a<>0&quot; (to break when the variable &quot;a&quot; changes from being zero). When the program is run, the watchpoint will not activate until control is returned to the module-level code. The program will break on the line &quot;PRINT 'After call',&quot; even though the value of variable &quot;a,&quot; was changed in the SUBprogram.

Additional query words: QuickBas BasicCom

Keywords: KB61340

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.