Buttons Example Code

Example Code

Buttons Function Reference

The following example shows how get the last button pressed and retrieve its name.

Private Sub tmrButtons_Timer()
    Dim lButton As Long
    Dim lKey1 As Long
    Dim lKey2 As Long

    lButton = sButtons(1234567890, lKey1, lKey2)

    If lButton = 0 Then
        lblButton.Caption = ""
    Else
        If lKey2 = 0 Then
            lblButton.Caption = ButtonName(lKey1)
        Else
            lblButton.Caption = ButtonName(lKey1) & " (" & ButtonName(lKey2) & ")"
        End If
    End If
End Sub


Public Function ButtonName(iButton As Integer) As String
    Dim sName As String
    sName = Space(25)
    sButtonName sName, iButton
    ButtonName = StripString(sName)
End Function

Public Function StripString(sSource As String) As String
    Dim lEnd As Long

    lEnd = InStr(sSource, Chr(0))
    If lEnd > 0 Then
        StripString = Mid(sSource, 1, lEnd - 1)
    Else
        StripString = sSource
    End If
End Function