AnsweredAssumed Answered

Passing Button Name  to function

Question asked by alanR on Dec 7, 2017
Latest reply on Dec 11, 2017 by kduffy

Hi ,

 

I have several button  with names that have the same name as elements in AF system explorer. Im trying to make each button call the same function . So for example i have a Button called Room_A , on click it calls a function called TestButtonToggle_Click(). In this function i would like to pass in the button name  which would return a value from AF with an element of the same name.

How would i go about doing this?

 

What i have tried below;

 

My code;

Public Sub TestButtonToggle_Click(ByVal lvarX As Long, ByVal lvarY As Long)

 

 

    Dim pbButtons As SelectedButton

    Dim pbButton As Button

    Dim Cell As String

 

    Set pbButtons = ThisDisplay.SelectedButtons

    If pbButtons.Count = 0 Then

        Exit Sub

    End If

 

    For Each pbButton In pbButtons

        If InStr(buttonName.name, "Room") Then

            Room = Mid(buttonName.name, 6, Len(buttonName.name))

              'Pass number to function below

            ToggleRoomState (Room)

            Exit Sub

        End If

    Next pbSymbol

End Sub

Outcomes