1 2 3 | Private Sub CommandButton1_Click() Call PasswordCheck ' call sub PasswordCheck when button check click End Sub |
1 2 3 4 5 | Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) If KeyCode = 13 Then 'enter key Call PasswordCheck 'call sub PasswordCheck when Enter key presed End If End Sub |
1 2 3 4 5 6 7 8 9 10 11 12 13 | Sub PasswordCheck() With UserForm1 If .TextBox1.Text = "abc" Then 'if input = abc (corret) .CommandButton2.Enabled = True 'enable button 2 .CommandButton1.Enabled = False 'disable button 1 .Label1 = "Password correct" 'write to label1 Else 'password is incorrect .Label1 = "Password incorrect, please try again" 'write to label End If End With End Sub |
Download File
No comments :
Post a Comment