Author Topic: BevelButtonDisplay  (Read 2349 times)

Darrell

  • Full Member
  • ***
  • Posts: 198
  • Electrician / PLC Technician
    • View Profile
BevelButtonDisplay
« 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
« Last Edit: January 31, 2017, 05:17:00 PM by Darrell »

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: BevelButtonDisplay
« Reply #1 on: January 31, 2017, 05:34:21 PM »
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:
Code: [Select]
   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

dmroeder

  • Global Moderator
  • Full Member
  • *****
  • Posts: 206
    • View Profile
Re: BevelButtonDisplay
« Reply #2 on: January 31, 2017, 05:38:21 PM »
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:

Code: [Select]
        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.
« Last Edit: January 31, 2017, 05:40:17 PM by dmroeder »

Darrell

  • Full Member
  • ***
  • Posts: 198
  • Electrician / PLC Technician
    • View Profile
Re: BevelButtonDisplay
« Reply #3 on: January 31, 2017, 09:14:41 PM »
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

dmroeder

  • Global Moderator
  • Full Member
  • *****
  • Posts: 206
    • View Profile
Re: BevelButtonDisplay
« Reply #4 on: February 01, 2017, 12:00:14 AM »
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)

Darrell

  • Full Member
  • ***
  • Posts: 198
  • Electrician / PLC Technician
    • View Profile
Re: BevelButtonDisplay
« Reply #5 on: February 01, 2017, 08:33:22 AM »
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
« Last Edit: February 01, 2017, 08:40:53 AM by Darrell »