AdvancedHMI Software
General Category => Open Discussion => Topic started by: Darrell on January 31, 2017, 05:13:53 PM
-
IS there a way to add the option . when the button is clicked a message box will appear and ask (are you sure) yes or no . if yes , then it does what the button is supposed to do , If no is clicked the massage disappears and nothing happens.
Properties window
display message box - yes/no
Text for message
Darrell
-
You can do this with a few lines of code. Leave the PLCAddressClick property empty because you will be writing the value via code.
- Right click the button and select View Code
- Add this code:
Private Sub BevelButtonDisplay1_Click(sender As Object, e As EventArgs) Handles BevelButtonDisplay1.Click
If MsgBox("Are You Sure?", vbYesNo) = DialogResult.Yes Then
ModbusRTUCom1.Write("40001", "1")
End If
End Sub
- change the Name after Handles to match the name of your specific button
-
You could use a regular vb button with some code, then use the driver in code do do the function. Add something like this to the button click of a button:
Dim button_value As Integer = MessageBox.Show("Would you like me to do that thing?", "Up to you...", MessageBoxButtons.YesNo)
If button_value = 6 Then '6 = yes
EthernetIPforCLXCom1.Write("The tag", 0)
End If
edit: I'm way slow. I like that DialogResult.Yes, learned something new.
-
I have no way to test this right now but , if I click yes in this basic label it would put a 1 in BOOL[0].11 is this correct
Private Sub BasicLabel34_Click(sender As Object, e As EventArgs) Handles BasicLabel34.Click
If MsgBox("Are You Sure?", vbYesNo) = DialogResult.Yes Then
EthernetIPforCLXCom1.Write("BOOL[0].11", "1")
End If
End Sub
-
I have no way to test this right now but , if I click yes in this basic label it would put a 1 in BOOL[0].11 is this correct
Private Sub BasicLabel34_Click(sender As Object, e As EventArgs) Handles BasicLabel34.Click
If MsgBox("Are You Sure?", vbYesNo) = DialogResult.Yes Then
EthernetIPforCLXCom1.Write("BOOL[0].11", "1")
End If
End Sub
That looks like it would do it. Keep in mind that it will stay a 1 unless there is something that writes it to zero. Depending on what you are after, you may want to consider writing a zero after that. Or I think there is a mouse up event that may be a place to write a zero. Just a thought.
Unrelated, having a word type named "BOOL" is a bit confusing. (see what I did there)
-
BOOL[0].11 is just an address I picked out af a program that I had for the example , all i want to do is toggle the bit on, when yes is clicked , as you probably know some people like to click buttons , this will just give them the chance to back out .
This would be a nice option to have with some of the controls in the properties window without having to add code
Thanks guys,
Darrell