AdvancedHMI Software

General Category => Support Questions => Topic started by: CBaker on March 09, 2022, 10:50:04 AM

Title: KeyboardInput output help
Post by: CBaker on March 09, 2022, 10:50:04 AM
Hello,

I have a KeyboardInput component in my application, and I'm trying to have the user confirm their input before sending it off to my PLC. I have a KeyboardInput1_EnterKeyPressed event that triggers a messagebox, which asks the user "You entered <partnumber>. Is this correct?" and has a Yes button and a No button.

I then want to check the result of the messagebox and log the change and output it to the PLC if it is yes. How can I set it up so that it only sends my input if I select Yes?
Title: Re: KeyboardInput output help
Post by: Archie on March 09, 2022, 11:52:51 AM
One way to do this is to create a customized KeyboardInput that prompts the user

- Right click the AdvancedHMIControls project and select Add->New Item
- Select type of Class and name KeyboardInputPrompt
- Enter this code

Public Class KeyboardInputPrompt
    Inherits AdvancedHMIControls.KeyboardInput

    Protected Overrides Sub OnEnterKeyPressed(e As EventArgs)

        Dim result As DialogResult = MessageBox.Show("Are you Sure?", "prompt", MessageBoxButtons.YesNo)
        If result = DialogResult.Yes Then
            MyBase.OnEnterKeyPressed(e)
        End If
    End Sub

End Class

- Rebuild the solution

 You should now have a KeyboardInputPrompt in the Toolbox


Title: Re: KeyboardInput output help
Post by: CBaker on March 09, 2022, 12:15:34 PM
That is exactly what I needed.

Thanks a lot!