|
楼主 |
发表于 2019-8-22 13:48
|
显示全部楼层
本帖最后由 YZC51 于 2019-8-22 13:51 编辑
谢谢老师指教!代码已经修改!烦请老师测试!为了不浪费论坛资源,待测试正常后再上传附件!再次致谢!
Private Sub CommandButton1_Click()
Dim Sh
't = 0
'Application.ScreenUpdating = False
If ComboBoxUser.Text = "" Then
MsgBox "用户名不能为空!", vbCritical, "提示!"
Exit Sub
End If
t = t + 1
Set Sh = Sheets("设置")
s = Sh.Range("A2:A65536").Find(ComboBoxUser, , , xlWhole).Row '查找用户在A列的位置
If TextPassword.Text = Sh.Range("B" & s).Text Then
' Call 隐藏表
Sheet1.Visible = 2
Sh.[C2] = ComboBoxUser.Text: Sh.[C3] = TextPassword.Text: Sh.[C4] = Now
If Sheet12.[J7] = 1 Then Sh.[C5] = "切换" Else Sh.[C5] = "登录"
With Sheet12
.ScrollArea = "$D$6:$J$15"
.[D4] = Sheets("设置").[C2]: .[J4] = Sheets("设置").[C4]
.[H12] = 1: .[glqy] = "备用中"
For i = 4 To 13
If s > 1 Then b = Sheets("设置").Cells(s, i).Value Else Exit For
If b = 1 Then '单元格为1时,有权限打开这个表
n = (((i - 4) Mod 5) + 1) * 2 + 4
If i < 9 Then .Cells(n, 4) = Sheets("设置").[C2]
If i > 8 Then .Cells(n, 6) = Sheets("设置").[C2]
End If
Next
.[H12] = 0
End With
Call 操作记录
Unload Me
t = 0
Else
If t >= 3 Then
Unload Me
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
Application.Visible = True
t = 0
Exit Sub
End If
MsgBox "密码错误!您还有" & 3 - t & "次机会!", vbCritical, "提示!"
TextPassword.Text = ""
TextPassword.SetFocus
Exit Sub
End If
Application.Visible = True
Sheets("登录").[G9].Select
Call 状态条
'Application.ScreenUpdating = True
End Sub |
评分
-
3
查看全部评分
-
|