Events


The syntax for declaring an event is:

  [accessibility] [Shadows] Event event_name(parameters) 

The accessibility clause can take one of the following values: Public, Protected, Friend, Protected Friend, or Private.

Use the Shadows keyword to indicate that the event shadows an item with the same name in the parent class. Any type of item can shadow any other type of item. For example, an event can shadow a subroutine, function, or variable. This would be rather bizarre and confusing, but it is possible.

The parameters clause specifies the parameters that you will pass when raising the event. An event handler catching the event will receive those parameters. Use ByRef parameters to allow the event handler to provide feedback to the code that raises the event.

The syntax for raising an event is as follows:

  RaiseEvent event_name(parameters) 

The parameters that you pass to the event handler must match those declared in the Event statement.

The following code shows pieces of a SeatAssignment class that raises a NameChanged event when its

  Public Class SeatAssignment     Public Event NameChanged()     ...     Private m_Name As String     Public Property Name() As String         Get             Return m_Name         End Get         Set(ByVal value As String)             m_Name = value             RaiseEvent NameChanged()         End Set     End Property     ... End Class 




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net