在VBA中返回excel表时 ,为什么会提示身份错误?

在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
请高说帮我看看哪里错了,我就是找不出来,请多多帮忙,真的很感谢了

在语句:主窗体.Show后退出过程: Exit 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
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-01-06
俺也不会 嘿嘿

相关了解……

你可能感兴趣的内容

大家正在搜

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网