用户登录界面设计小问题,求助
一个用户登录界面有 FORM1和 form2组成以下是form1输入用户名和密码的代码
Private Sub Command1_Click()
If Txt1.Text = "user" Then
txt2.SetFocus
ElseIf Txt1.Text <> "user" Then
MsgBox "请输入正确的用户名!", vbOKOnly + vbInformation, "注意"
End If
If txt2.Text = "123456" And Txt1.Text = "user" Then
Form1.Hide
Form2.Show
ElseIf txt2.Text <> "123456" Then
MsgBox "请输入正确的密码", vbOKOnly + vbInformation, "注意"
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Form1.Show
Form2.Hide
End Sub
Private Sub Txt1_KeyDown(KeyCode As Integer, Shift As Integer)
If Txt1.Text = "user" And KeyCode = vbKeyReturn Then
txt2.SetFocus
ElseIf Txt1.Text <> "user" And KeyCode = vbKeyReturn Then
MsgBox "请输入正确的用户名!", vbOKOnly + vbInformation, "注意"
Txt1.Text = ""
End If
End Sub
Private Sub txt2_KeyDown(KeyCode As Integer, Shift As Integer)
If txt2.Text = "123456" And Txt1.Text = "user" And KeyCode = vbKeyReturn Then
Form1.Hide
Form2.Show
ElseIf txt2.Text <> "123456" And KeyCode = vbKeyReturn Then
MsgBox "请输入正确的密码", vbOKOnly + vbInformation, "注意"
txt2.Text = ""
End If
If txt2.Text = "123456" And Txt1.Text <> "user" And KeyCode = vbKeyReturn Then
MsgBox "请输入正确的用户名", vbOKOnly + vbInformation, "注意"
Txt1.Text = ""
End If
End Sub
以下是form2系统退出代码
Option Explicit
Private Sub Command1_Click()
Form1.Show
End Sub
现在系统退出后,退到form1的登录界面,想实现用户名和密码清除,添加 txt1.text""出错,求高手请教如何解决。谢谢