Author Topic: BasicButton WriteToValue as a Variable  (Read 1172 times)

thebestg2002

  • Newbie
  • *
  • Posts: 26
    • View Profile
BasicButton WriteToValue as a Variable
« on: April 01, 2015, 11:40:14 PM »
I have a basic button that I would like to use as a download button. It needs to write a value to a Modbus RTU based PLC. I loaded the applicable address in the click event and I am able to write a constant value without any issues. What I need to be able to do though is write a value that is a variable as opposed to a constant value. Is there a simple method for doing this? I am not a gifted vb.net programmer by any means so please take that into consideration.

Any help would be greatly appreciated.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5266
    • View Profile
    • AdvancedHMI
Re: BasicButton WriteToValue as a Variable
« Reply #1 on: April 02, 2015, 07:13:19 AM »
Method 1 using a normal button from the All Windows Toolbox group:

    Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
        Dim MyVariable As Integer
        MyVariable = 1000
        ModbusRTUCom1.Write("40001", MyVariable)
    End Sub



Method 2 using the BasicButton:

- Add a BasicButton to the form
- In the Properties Window set PLCAddressClick to 40001
- Set  OutputType to WriteValue
- Set ValueToWrite to any value you want to write
- In your code, change the value to write like this:

BasicButton1.ValueToWrite="99"