You can have a public variable that will count the number of pressed buttons, and the Index value in the Click event is the button's index.
e.g.:
Code:Dim lCnt As Long Dim bOK As Boolean Private Sub Command1_Click(Index As Integer) ' If the user clicked more than 5 buttons, exit the sub If Not bOK Then Exit Sub ' Record the reference Text1(lCnt).Text = Index ' Increase the counter lCnt = lCnt + 1 ' Make sure the user can't click more than 5 buttons If lCnt = 5 Then bOK = False End Sub




Reply With Quote