Page 74 - Open Soource Technologies 304.indd
P. 74
Event Driven Programming
Figure 3.20: Blank Form.
Now, add a TextBox and a Button to the form from the toolbox. The toolbox can be selected from
View->ToolBox on the main menu or by holding Ctrl+Alt+X on the keyboard. Once adding the
TextBox and Button is done, run the form. The output window displays a TextBox and a Button.
When you click the Button nothing happens. We need to write an event for the Button stating
something should happen when you click it. To do that get back to design view and double-click
on the Button. Doing that opens an event handler for the Button where you specify what should
happen when you click the button. That looks like this in code.
Public Class Form1
Inherits System.Windows.Forms.Form
#Region “ Windows Form Designer generated code “
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)_
Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As _
System.EventArgs) Handles Button1.Click
End Sub
End Class
68 LOVELY PROFESSIONAL UNIVERSITY