VISUAL BASIC TIP

Problem Code VBTPDEB001

Description

DEBUG PROJECT WITHOUT SETTING BREAK POINT.

VB Version Compatibility

This solution works in VB4,VB5,VB6 & VBA (Visual Basic For Application).

THEORY

Sometime you want to debug your project from a specific Line of Code. Then you set breakpoint on that line and whenever Program Execution comes to that line VISUAL BASIC breaks. 

VISUAL BASIC provides one more tool to do this. you can place STOP statement wherever you want to stop program execution. Program execution to come into break mode whenever this statement encountered. This is neat and clean method to debug and advantage and disadvantage of this method is if you close the project by mistake or change to another project breakpoint cleared off where as STOP method remains in the program.

TIP
  1. Start a new visual basic project.
  2. Add a COMMAND BUTTON on the default FORM.
  3. Write following code on the click() event .
    Private Sub Command3_Click()
       Dim i As Integer
       For i = 0 To 1000
           If i = 500 Then
              Stop
           End If
       Next
    End Sub
  4. Run The Project.
  5. Click the command button and you wil see that program execution stops when value of i becomes 500. now Program Execution Control is in your hand you can debug the project as usual.

--------------------X-X-X-X-X-X-X-X--------------------

SPECIAL NOTE :- ALTHOUGH this is tip is tested thoroughly. Using this tip is at user own risk. Visual Code is not responsible for any damage caused directly or indirectly.

BACK

1