event.................

Unknown | 7:30 PM |

defined in button class and will be raised when the
user clicks the button. The following example shows how the event can be
defined, raised in the class and used by the object user.
Declaration:- The event member will be declared with Event keyword. Basically
the event member should always be public. Because these are the members will
be used by the external users.
'Declare a class which operates on the Employee collection database
'This class is used to find some summarised operation on the Employee
'collction database, which means finding the relavent employee ‘information, 'getting the
total no. of employees in the collection and ‘others - Its just 'an example to explain how
event works
Public Class EmployeeCollection
'Declare an event which will be raised after finding the data
'Keyword ‘Event’ is used the declare the events
Public Event FindResult(ByVal blnFound As Boolean)
'This method is to find the data from employee colletion database and 'raise the findresult
event to return the result
Public Sub FindData(ByVal Name As String)
'find the Employee with name and return the result as boolean, if
'the data is found then raise FindResult with True else with
'False
Dim found As Boolean
found = FineEmployee(Name)
If found Then
'Raise the event with parameter
RaiseEvent FindResult(True)
Else
'Raise the event with parameter
RaiseEvent FindResult(False)
End If
End Sub
End Class
Usage:- In order to access the events of the objects, the object should be
declared with withevents clause. This is shown in the following example with form
load event.
'Declare the object with WithEvents clause to create an instance
Dim WithEvents objEmpColl As EmployeeCollection = New EmployeeCollection()
Public Sub load()
'Find the Employee with name Rama in the Employee collection
objEmpColl.FindData("Rama")
End Sub
'The following event will be raised after the search operation
Private Sub objObject_FindResult(ByValue blnFound as Boolean) Handles
objObject.FindResult
If blnFound Then
MsgBox("The given Employee is Found in the collection")
Else
MsgBox("The given Employee is not Found")
End If
End Sub

Category:

About http://dotnetvisual.blogspot.in/:
DOT NET TO ASP.NET is a web application framework marketed by Microsoft that programmers can use to build dynamic web sites, web applications and web services. It is part of Microsoft's .NET platform and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime, allowing programmers to write ASP.NET code using any Microsoft .NET language. create an application very easily ....