execute automatically?

bcm

Well-known member
Joined
Aug 13, 2007
Messages
56
Programming Experience
Beginner
i have written a code in vb.net. Its design contains buttons to execute various steps. Now i want my code to execute automatically run when I debug without pressing any buttons :confused:
 
You could use conditional compiler directives (#). For buttons there is the PerformClick method that can be called, else put the code in a method and call the method both from event handler and elsewhere.
VB.NET:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles MyBase.Load

#If DEBUG Then
        Button1.PerformClick()
#End If

    End Sub
The code inside the #If block here is only compiled into Debug builds.
 
Back
Top