An event refers either to user actions or input from other programs or sources. Event handling varies slightly in VB.NET from the VB 6.0 programming environment. VB.NET allows event handling to be turned on or off at run-time by using "AddHandler" or "RemoveHandler." The program handles the event by performing some action in the "event handler" function or subroutine. The program calls the click event of a "submit" button when the user clicks the "submit" button and the code in the event handler executes.
Step 1
Define a function or a subroutine to handle the click event. "Private Sub MyFunction(ByVal sender As Object, ByVal e As EventArgs) Handles Submit.Click, Send.Click" defines a subroutine where code is placed to react to the click event of the buttons named "Submit" and "Send."
Step 2
Code the appropriate actions to be performed after the click event of the "Submit" or "Send" button. These lines of code are contained within the subroutine called "MyFunction" and will execute each time the buttons are clicked.
Step 3
Use the "AddHandler" statement to associate an event with an event handler if you don't want to use the "Handles" statement shown in Step 1. Within the class, write an event handler subroutine defined as "Submit_Click(ByVal sender as object, ByVal e as EventArgs)." Add the line " AddHandler Submit.Click, AddressOf Submit_Click" when the event occurs.
Step 4
Remove an event handler from an event by coding "Private Sub RemoveMyButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DeleteMe.Click RemoveHandler Submit.Click, Addressof RemoveMyButton_Click." This code will prevent the event handling code from executing if the user click on the "Submit" button.
Published by Lora Covrett
I write professionally for several different online publications. My areas of expertise are computer and IT. I enjoy writing about politics as well. View profile
- Information on C#, C++, and VB.NETInformation to aid in deciding on which language most suits your Windows application development.
Why Microsoft's Visual Basic (VB) is Every Bit as Good a Programming Lan...The debate continues over which programming language is superior, Visual Basic (VB) or C#. One programmer voices his opinion on why the original is still the best.
Creating a HelloWorld Console Application Using VisualBasic.NETThis tutorial will walk you through the steps to create a simple console application in VisualBasic.Net (VB.Net). - The Best Tutorial Sites for Visual Basic.NETVisual Basic.NET is an interesting subject that more people should explore. In this essay I will explore three different tutorial sites and review them. I will also give my opinion on my favorite part of the site.
- Getting Started with the .NET FrameworkThe .NET Framework by Microsoft can be useful, annoying and confusing, all at the same time.
- How DataGridView in VB .Net Can Be Use for Representating Data when We Don't Want...
- Visual Basic: Hello World Application, and Message Box Overview
- Visual Basic: Mathematical Operations and Creating a Calculator
- Visual Basic: Create a Text Spammer
- Use Visual Basic to Calculate Simple Interest
- How to Read/Write/Delete Microsoft Windows Registry Keys/Values Using VB .Net?
- How to Send and Receive HTTP Web Request & Response in Vb .Net?




Comments are disabled on this content.