Message 1 of 3
Events Question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
What's is deferent between the next two code
Private Shared WithEvents docEvents As DocumentCollection
Private Shared Sub docEvents_DocumentDestroyed(sender As Object, e As DocumentDestroyedEventArgs) Handles docEvents.DocumentDestroyed
MsgBox(e.FileName & " docEvents_DocumentDestroyed")
End Sub
<CommandMethod("StartEventHandling")> _
Public Sub Asdkcmd()
docEvents = Application.DocumentManager
End Suband
Private Shared docDestroyedEvent As DocumentDestroyedEventHandler
Public Shared Sub OnDocumentDestroyed(ByVal sender As Object, ByVal e As DocumentDestroyedEventArgs)
MsgBox(e.FileName & " OnDocumentDestroyed")
End Sub
<CommandMethod("StartEventHandling")> _
Public Sub Asdkcmd()
Dim docs As DocumentCollection = Application.DocumentManager
If docDestroyedEvent Is Nothing Then
docDestroyedEvent = New DocumentDestroyedEventHandler(AddressOf OnDocumentDestroyed)
AddHandler docs.DocumentDestroyed, docDestroyedEvent
End If
End Sub
and what's the best for use