在VBA中添加了一个用户登录身份验证界面,在经过身份验证进入系统后,但是每当返回EXCEL表格时,总是显示提示身份错误,但这时我已经正确进入系统之中了在系统中操作了,这是怎么回事啊?????
用户登录设分验证码:
Private Sub CommandButton1_Click()
Static n As Integer
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox "请填写完整!"
End If
Worksheets("用户").Activate
m = 2
While Not IsEmpty(Cells(m, 1))
If UCase(TextBox1.Text) = UCase(Cells(m, 1)) And UCase(TextBox2.Text) = UCase(Cells(m, 2)) Then
n = 0
登录.Hide
Load 主窗体
主窗体.Show
Else
n = n + 1
'TextBox1.Text = ""
'TextBox2.Text = ""
'TextBox1.SetFocus
MsgBox "该用户名与对应的密码不存在,请核对!您还有" & 3 - n & "次登录机会!", vbOKOnly
End If
m = m + 1
Wend
If n >= 3 Then
For Each w In Workbooks
w.Saved = True
Next
Application.Quit
End If
End Sub
返回表中代码:
Private Sub Label8_Click()
主窗体.Hide
Application.WindowState = xlNormal
ActiveWindow.Left = 1
End Sub
请高说帮我看看哪里错了,我就是找不出来,请多多帮忙,真的很感谢了
Private Sub CommandButton1_Click()
Static n As Integer
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox "请填写完整!"
End If
Worksheets("用户").Activate
m = 2
While Not IsEmpty(Cells(m, 1))
If UCase(TextBox1.Text) = UCase(Cells(m, 1)) And UCase(TextBox2.Text) = UCase(Cells(m, 2)) Then
n = 0
登录.Hide
Load 主窗体
主窗体.Show
Exit Sub
Else
n = n + 1
'TextBox1.Text = ""
'TextBox2.Text = ""
'TextBox1.SetFocus
MsgBox "该用户名与对应的密码不存在,请核对!您还有" & 3 - n & "次登录机会!", vbOKOnly
End If
m = m + 1
Wend
If n >= 3 Then
For Each w In Workbooks
w.Saved = True
Next
Application.Quit
End If
End Sub