Example 2: Custom Response to Specific Alarms

Example 1 illustrates how to set up the basic connection between a custom event handler and the chart. Shown below is the code for a custom event handler that will fire every time that an out-of-control sample is encountered.

Private Sub SourceObj_SampleOutOfControl(ByVal Obj As Object, _

SampleID() As String, _

PartId() As String, _

ByVal NewSample As Boolean, _

ByVal flags As Long)

 Dim message As String

 message="Out of control alarm" + vbCr + vbCr + _

"Sample ID: "+SampleID(0) + vbCr + _

"Is this a new sample (alarm)? " + Str(NewSample)

 MsgBox message

End Sub

If an out-of-control sample (alarm) occurred at a sample labeled "12:11:51 PM", you would see the following dialog.

Note how the sample name is passed into the event handler routine as an array of strings; for some alarms such as runs tests, chart violations (alarms) apply to ranges of samples. Also, variable NewSample is a logical (boolean) variable that is true, if the current sample is a new sample (read for the first time into the chart object; see also General Design and New Features).