作业帮 > 综合 > 作业

英语翻译Private Sub Text1_KeyUp(KeyCode As Integer,Shift As Inte

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/06/16 13:26:14
英语翻译
Private Sub Text1_KeyUp(KeyCode As Integer,Shift As Integer)
Static i As Integer
If KeyCode = 13 Then
If (Text1.Text) = "abcd" Then
Label2.Caption = "你已成功进入"
ElseIf i < 3 Then
i = i + 1
MsgBox "口令错!请重新输入"
Text1.SetFocus
Else
MsgBox "你无权进入系统"
End If
End If
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer,Shift As Integer)
'Text1的键盘按下事件
Static i As Integer '声明变量i
If KeyCode = 13 Then '如果按下回车
If (Text1.Text) = "abcd" Then '如果Text1中的内容是abcd
Label2.Caption = "你已成功进入" 'Label2显示
ElseIf i < 3 Then '如果i小于3
i = i + 1 'i增加1
MsgBox "口令错!请重新输入" '对话框
Text1.SetFocus 'Text1得到焦点
Else
MsgBox "你无权进入系统" '对话框
End If
End If
End Sub
'这个程序虽然执行起来是没有问题的,但是3次输入的限制是起不到作用的,可以改成下面这样
Private Sub Text1_KeyUp(KeyCode As Integer,Shift As Integer)
Static i As Integer
If KeyCode = 13 Then
If i < 3 Then
If (Text1.Text) = "abcd" Then
Label2.Caption = "你已成功进入"
Else
MsgBox "口令错!请重新输入"
Text1.SetFocus
End If
Else
MsgBox "你无权进入系统"
End If
i = i + 1
End If
End Su