Author Topic: Adding a New PLCAddressXXXX Property to a Control  (Read 4750 times)

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Adding a New PLCAddressXXXX Property to a Control
« on: June 08, 2016, 08:43:16 PM »
If you ever run into the situation in which you want to control another property of a control through a PLC register/tag, this walk through will show you how to add a new PLCAddressXXXX property. You may be quite surprised at how easy it is to do.

In this Walk Through, I will show how to control the Maximum property of the Meter2 by a value in the PLC.

1) In Solution Explorer, expand down the AdvancedHMIControls Project
2) Expand down the Controls folder
3) Look for Meter2.vb
4) Right click Meter2.vb and select View Code
5) Look for a code region named "PLC Related Properties" It may be collapsed and you will need to expand it down. If it is not collapsed, you will look for #Region "PLC Related Properties"
6) Go to the bottom of that code region. It will be marked with an #End Region
7) Just above the #End Region, insert this line of code:
Code: [Select]
Public Property PLCAddressMaximum As String
8 ) Build the solution
9) Open the MainForm and add a Meter2 to your form
10) In the Properties Window, you should now see a new property PLCAddressMaximum

VERY IMPORTANT NOTE:
The name of the property added to the code must match exactly including case. If everything matches, then putting a valid PLC address in the property will let the value from the PLC control the Maximum property.

This method can be used on any AdvancedHMI control, but can only be used on properties of a numeric, boolean, or string type. It cannot be used on complex types such as location or size.