Author Topic: KeyboardInput output help  (Read 871 times)

CBaker

  • Newbie
  • *
  • Posts: 2
    • View Profile
KeyboardInput output help
« 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?

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: KeyboardInput output help
« Reply #1 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


« Last Edit: March 09, 2022, 11:56:28 AM by Archie »

CBaker

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: KeyboardInput output help
« Reply #2 on: March 09, 2022, 12:15:34 PM »
That is exactly what I needed.

Thanks a lot!