Changes

Jump to: navigation, search

A Simple Visual Basic Example

1,279 bytes added, 18:42, 16 July 2007
Creating an Event
End Sub
</pre>
 
This is a Visual basic Subroutine where code is placed to define what happens when a Click event is detected on the button (i.e the user clicks on the button in the user interface of our application). In this example we want the application to close when the closeButton is pressed. To achieve this we add a single line of Visual Basic code to the closeButton_Click() sub-routine as follows:
 
<pre>
Private Sub closeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closeButton.Click
Close()
End Sub
</pre>
 
== Building and Running a Visual Basic Application ==
 
Now that we have completed the design and implementation of a simple Visual basic application we can compile and run it. To do so ''Build myVBapp'' from the Visual Studio ''Build'' menu. Assuming there are no problems the application should compile without any errors (the message ''Build succeeded'' should appear in the status bar at the bottom of the Visual Studio screen).
 
Once build the application can be run by selecting ''Start Debugging'' from the ''Debug'' menu. After a few seconds the application should appear. Click on the ''Close'' button to close the application.
 
Congratulations - you have designed, built and run your first Visual Basic application.

Navigation menu