Private Sub CommandButton1_Click() Dim name, str, n As String Dim pw As String name = TextBox1.Value pw = TextBox2.Value If name = "" Or pw = "" Then MsgBox "用户名或密码不能为空!请输入", 64 Else n = Sheets("用户").Range("A65536").End(xlUp).Row n = Sheets("用户").Range("A:B").Find(name, SearchOrder:=xlByRows, SearchDirection:=xlNext).Row str = Sheets("用户").Cells(n, 1) If Sheets("用户").Cells(n, 1) = name And Sheets("用户").Cells(n, 2) = pw Then MsgBox "登录成功!" Unload UserForm1 Application.Visible = True Else MsgBox "信息不对,请重新输入" End If End If End Sub 这样对吗? |