

' Create main menu MyMainMenu = New MainMenu( ) ' Define menu items mnuWindow = New MenuItem( ) mnuTileHoriz = New MenuItem( ) mnuTileVert = New MenuItem( ) mnuCascade = New MenuItem( ) mnuArrangeAll = New MenuItem( ) ' Set menu properties mnuWindow.Text = "&Window" mnuWindow.MdiList = True mnuTileHoriz.Text = "Tile Horizontally" mnuTileVert.Text = "Tile Vertically" mnuCascade.Text = "Cascade" mnuArrangeAll.Text = "Arrange Icons" ' Add items to menu (mnuWindow) (mnuCascade) (mnuTileHoriz) (mnuTileVert) (mnuArrangeAll) ' Assign menu to form Me.Menu = MyMainMenuĭim m圜hild As New DocumentForm("My Document", Me)
#Vb net 2010 mdi menu merge windows
' Declare MainForm's main menu Private myMainMenu As MainMenu ' Declare Windows menu Protected WithEvents mnuWindow As MenuItem Protected WithEvents mnuTileHoriz As MenuItem Protected WithEvents mnuCascade As MenuItem Protected WithEvents mnuTileVert As MenuItem Protected WithEvents mnuArrangeAll As MenuItem WriteLine ( "Minute's Event" ) End Sub Private Sub mobjTimer_evtHour ( ByVal xintTime As Integer ) _ Handles mobjTimer. WriteLine ( "Second's Event" ) End Sub Private Sub MinuteEvent ( ByVal xintTime As Integer ) Console. Sleep ( 100 ) End While End Sub Private Sub SecondEvent ( ByVal xintTime As Integer ) Console. evtMinute, AddressOf MinuteEvent While ( mobjTimer. SecondDel ( AddressOf SecondEvent )) AddHandler mobjTimer.
#Vb net 2010 mdi menu merge mod
Combine ( evtSecond, objSecond ) End Sub Public Sub OnTimer () lngSeconds = lngSeconds + 1 If lngSeconds Mod 5 = 0 Then evtSecond ( lngSeconds ) End If If lngSeconds Mod 10 = 0 Then RaiseEvent evtMinute ( lngSeconds ) End If If lngSeconds Mod 30 = 0 Then RaiseEvent evtHour ( lngSeconds ) End If End Sub End Class Public Class CClock Private WithEvents mobjTimer As CTimer Sub New () mobjTimer = New CTimer () mobjTimer. To run the sample from command line use - vbc /out:Event.exe Event.vb Imports System Public Class CTimer Delegate Sub SecondDel ( ByVal xintTime As Integer ) Private evtSecond As SecondDel Public Event evtMinute As SecondDel Public Event evtHour ( ByVal xHour As Integer ) public Shared lngSeconds As Long Public Sub Register ( ByVal objSecond As SecondDel ) evtSecond = evtSecond. Another class CClock is defined that has members to handle the RaisedEvents from CTimer class.

The class also provides mechanism to register event and raises events with intervals simulating 5, 10 and 30 units of the interval. The example shown declares a delegate in class CTimer and also declares three events in the class using all the aforementioned declarations.

The event is raised by making a call to RaiseEvent.ĭeclaring a sub and either attaching it to the delegate or registering with the event declaring class can handle the event. The event is implemented by using implicitly declared delegate by the framework. Public Event evtSample(Cancel as Boolean) - event handler procedure would be registered by using Handles keyword in the declaration itself. The event is raised by making a call to RaiseEvent. The event is implemented by using the above-declared delegate. Public Event evtSample as sampleDel - event handler can be registered by using AddHandler method in the Class that would provide the Handler. The event is raised by making a call to evtSample. The event is implemented by using explicitly declared delegate. Delegate can be declared as Delegate Sub sampleDel ( ByVal Cancel As Boolean )Īny method that has same signature can be attached to this delegate procedure that would have the same signature can handle this event.ĮvtSample As sampleDel - mechanism to register the event handler for this type of declaration is to be provided by the class declaring the event. Delegate class has signature, and it can hold references only to methods that match its signature.
