Private Sub CommandButton1_Click()
Dim hwd As Long
lTimeID = timeSetEvent(10, 0, AddressOf TimeProc, 1, 1)
aa = InputBox("请输入字符", "密码inputbox")
' DoEvents
If aa = 123456 Then
MsgBox "密码正确!可以登录"
Else
MsgBox "密码错误!"
End If
End Sub
Sub 命令密码开关() '要执行命令必须正确输入密码方能执行命令,
Dim mycode$, i%
Do While i <= 3
mycode = InputBox("请输入密码")
i = i + 1
If mycode = "" Then Exit Sub
If mycode <> Sheet1.Range("I12") Then '需要输入的密码等于【Sheet1.Range("I12")】内容
MsgBox "输入密码错误,请重新输入"
Else
ThisWorkbook.Unprotect (mycode)
Exit Do
End If
Loop
If i > 3 Then '大于3次,第4次后自动关闭
MsgBox "密码超次输入,不能执行以下命令!"
Exit Sub
End If
'密码正确后 执行的命令
End Sub