Validate

<< Click to Display Table of Contents >>

 

Validate

Validate(Cancel, NewValue)

Occurs after testing SetPoint limits (please check MinLimit, MaxLimit, and EnableLimits properties) and before sending a SetPoint value to a Tag. The purpose of this event is allowing users to cancel sending SetPoint's value to a Tag.

The Cancel parameter is a Boolean that indicates if attributing a SetPoint's value to a Tag must be canceled (Cancel equal to True). Default is False, that is, SetPoint's value is sent to a Tag. NewValue is the evaluated value. The old value can be accessed in SetPoint's Value property. The next script contains an example of using this event.

Sub Text1_Validate(Cancel, NewValue)
  ' Displays a MessageBox that asks a user
  ' if the new SetPoint value should be used
  message = "Current value: " & value & vbnewline & _
    "New value: " & NewValue & vbnewline & vbnewline & _
    "Do you accept the new value?"
  If MsgBox (message, vbQuestion + vbYesNo, _
    "Validate Event") = vbNo Then
    Cancel = True
  End If
End Sub

Was this page useful?