Author Topic: Button Text changing based on address state  (Read 1015 times)

ekmaust

  • Newbie
  • *
  • Posts: 2
    • View Profile
Button Text changing based on address state
« on: June 05, 2014, 03:52:13 PM »
I am writing a fairly simple program that allows me to enable/disable the air conditioning in each room of my house. I'm using a MicroLogix 1400. I have a simple button (address N10:5/5) that toggles the A/C on and off.

I want the button to say 'Enable' when N10:5/5 = 0 and 'Disable' when it = 1. I have this line of code that works fine:

Code: [Select]
If EthernetIPforPLCSLCMicroCom1.Read("N10:5/6") = True Then AptBtn.Text = "Disable" Else AptBtn.Text = "Enable"

The only problem is that I have this code written within the AptBtn.Click method. This means that it only reads the address/updates the text when I am actively clicking the button.

Long story short, is there any way to have my program continuously checking the address and updating the text accordingly? Where would I put this line of code in order to do so?

As a side note, I also tried adding this line of code directly into the button initialization, but it would break with an error every time I tried to open that page.

I am fairly new to this, so any advice is appreciated!!

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5280
    • View Profile
    • AdvancedHMI
Re: Button Text changing based on address state
« Reply #1 on: June 05, 2014, 03:58:58 PM »
You can eliminate your code, this functionality already exists in a BasicButton. Try this:

- Add a BasicButton to your form
- Set the Text property to "Enable"
- Set the TextAlternate property to "Disable"
- Set OutputType to Toggle
- Set PLCAddressClick to N10:5/6
- Set PLCAddressSelectTextAlernate to N10:5/6