Author Topic: Change Button Text  (Read 1369 times)

Darrell

  • Full Member
  • ***
  • Posts: 198
  • Electrician / PLC Technician
    • View Profile
Change Button Text
« on: August 30, 2015, 11:06:20 PM »
I have two buttons one to enable subscription and the other to disable , I would like to use just one button to do the same thing

The button text says enable subscriptions , then when clicked, it enables subscriptions and then changes the text on the button to say disable subscription and the next time it is clicked it would disable subscriptions and revert back to the original text.

Darrell

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: Change Button Text
« Reply #1 on: August 31, 2015, 12:59:03 AM »
You could possibly use a code like this to have a button behave as maintained switch (with initial state set to button showing "Enable Subscriptions" and the driver property DisableSubscriptions set to True):

Code: [Select]
    Private hold As Boolean
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Not Me.hold Then
            Me.Button1.Text = "Disable Subscriptions"
            Me.EthernetIPforPLCSLCMicroCom1.DisableSubscriptions = False
            Me.hold = True
        Else
            Me.Button1.Text = "Enable Subscriptions"
            Me.EthernetIPforPLCSLCMicroCom1.DisableSubscriptions = True
            Me.hold = False
        End If
    End Sub
« Last Edit: August 31, 2015, 01:07:57 AM by Godra »