hexagon logo

How to: Handle PCDMIS events (when working with Visual Basic 2008)

Hi there,

It took me a full 20 minutes to figure this out (Blush) - so for anyone who may be struggling to pick up and handle a PCDMIS event in VB 2008 because of one stupid missing little piece of code -- here it is:

In the reference manual it gives you this excample:

Public Class PCDMISHelper
    Dim myPCDApp As PCDLRN.Application
    Dim WithEvents [B]AppEvents[/B] As PCDLRN.ApplicationObjectEvents
    Const PCDMIS_DAEMON As String = "PCDLRN"

    Sub New()
        LaunchPCDMIS()
    End Sub

    Private Sub LaunchPCDMIS()
        myPCDApp = DirectCast(CreateObject("PCDLRN.Application"), PCDLRN.Application)
        AppEvents = myPCDApp.ApplicationEvents
    End Sub

[B]Private Sub AppEvents_OnEndExecution( ByVal pp As PCDLRN.IPartProgram, ByVal tt As Long)
        [/B]MsgBox "ENDING EXECUTION". Click OK to continue."[B]
End Sub[/B]
.
.

For Visual Basic 2008 code, you must handle pcdmis events like this:
.
.
[COLOR=Red][scroll to the right [B]--->[/B]][/COLOR]
[B]Private Sub AppEvents_OnEndExecution( ByVal pp As  PCDLRN.IPartProgram, ByVal tt As Long) [COLOR=Red]Handles AppEvents.OnEndExecution[/COLOR]
        [/B]MsgBox "ENDING EXECUTION". Click OK to continue."[COLOR=YellowGreen]' blah blah blah[/COLOR]
[B] End Sub
[/B]
...as easy as that.