Just remember that, in general, once you modify the code of any control then all controls of that kind, which you might have on your forms, will adopt that modification.
You can try the modifications as below:
Private Sub KeypadPopUp_ButtonClick(ByVal sender As Object, ByVal e As MfgControl.AdvancedHMI.Controls.KeypadEventArgs)
If e.Key = "Quit" Then
KeypadPopUp.Visible = False
ElseIf e.Key = "Enter" Then
If String.IsNullOrEmpty(m_KeypadPasscode) Or PasscodeValidated Then
If m_ComComponent Is Nothing Then
DisplayError("ComComponent Property not set")
Else
If Not String.IsNullOrEmpty(KeypadPopUp.Value) Then
Try
If m_KeypadMaxValue <> m_KeypadMinValue Then
If KeypadPopUp.Value < m_KeypadMinValue Or KeypadPopUp.Value > m_KeypadMaxValue Then
System.Windows.Forms.MessageBox.Show("Value must be >" & m_KeypadMinValue & " and <" & m_KeypadMaxValue)
Exit Sub
End If
End If
Catch ex As Exception
System.Windows.Forms.MessageBox.Show("Failed to validate value. " & ex.Message)
Exit Sub
End Try
Try
If KeypadScaleFactor = 1 Or KeypadScaleFactor = 0 Then
m_ComComponent.Write(m_PLCAddressKeypad, KeypadPopUp.Value)
Else
m_ComComponent.Write(m_PLCAddressKeypad, CDbl(KeypadPopUp.Value) / m_KeypadScaleFactor)
End If
Catch ex As Exception
System.Windows.Forms.MessageBox.Show("Failed to write value. " & ex.Message)
End Try
End If
KeypadPopUp.Close()
KeypadPopUp = Nothing
End If
Else
'* A passcode was entered, so validate
If Not String.IsNullOrEmpty(KeypadPopUp.Value) AndAlso KeypadPopUp.Value = m_KeypadPasscode Then
PasscodeValidated = True
PromptNewValue()
Else
System.Windows.Forms.MessageBox.Show("Invalid Passcode!")
KeypadPopUp.Close()
KeypadPopUp = Nothing
End If
End If
End If
End Sub
'***********************************************************
'* If label is clicked, pop up a keypad for data entry
'***********************************************************
Protected Overrides Sub OnClick(e As System.EventArgs)
MyBase.OnClick(e)
If m_PLCAddressKeypad IsNot Nothing AndAlso (String.Compare(m_PLCAddressKeypad, "") <> 0) And Enabled Then
If KeypadPopUp Is Nothing Then
KeypadPopUp = New MfgControl.AdvancedHMI.Controls.KeypadV2(m_KeypadWidth)
AddHandler KeypadPopUp.ButtonClick, AddressOf KeypadPopUp_ButtonClick
End If
If String.IsNullOrEmpty(m_KeypadPasscode) Then
PromptNewValue()
Else
PromptPasscode()
End If
End If
End Sub
Private Sub PromptNewValue()
KeypadPopUp.Text = m_KeypadText
KeypadPopUp.ForeColor = m_KeypadFontColor
KeypadPopUp.MinValue = m_KeypadMinValue
KeypadPopUp.MaxValue = m_KeypadMaxValue
KeypadPopUp.Value = ""
KeypadPopUp.StartPosition = Windows.Forms.FormStartPosition.CenterScreen
KeypadPopUp.TopMost = True
KeypadPopUp.Show()
End Sub
Private PasscodeValidated As Boolean
Private Sub PromptPasscode()
PasscodeValidated = False
KeypadPopUp.Text = "Enter Passcode"
KeypadPopUp.ForeColor = m_KeypadFontColor
KeypadPopUp.Value = ""
KeypadPopUp.StartPosition = Windows.Forms.FormStartPosition.CenterScreen
KeypadPopUp.TopMost = True
KeypadPopUp.Show()
End Sub