如果还有不懂,再问吧.
Public Sub aaaaaaaa()
Dim inName As String '输入用户名
Dim inPwd As String '输入密码
Dim rightPwd As String '检索到的密码
inName = "user01" '测试用户名
inPwd = "pwd09" '测试密码
On Error Resume Next
'根据用户名检索正确密码
rightPwd = WorksheetFunction.VLookup(inName, Sheet1.Range("A2:B6"), 2, False)
If rightPwd <>"" And rightPwd = inPwd Then
MsgBox "正确"
Else
MsgBox "错误"
End If
End Sub
不过用excel做的登录界面很容易就会被破解的,给不太懂的人用用还可以,呵呵.就当作玩玩和学习吧.
有邮箱吗,我发一个给你
主要思路是:在open事件里面,把所有工作表都深度隐藏,用户输入用户名和密码后,就把与该用户相关的工作表取消隐藏,并保护工作薄,那么该用户没有密码就不能取消其它的工作表隐藏,就只能看到与自己相关的几个工作表了:
Private Sub Workbook_Open()
Windows(Windows.Count).Visible = True '是否起用宏,不启用宏就退出工作薄
On Error Resume Next
Application.ScreenUpdating = False
'ActiveWindow.WindowState = xlMinimized '最少化login窗口
Call UnProWB
ThisWorkbook.Worksheets("Login").CommandButton1.Visible = False
Worksheets("Login").Visible = True
For Each sht In Worksheets
If sht.Name <> "Login" Then sht.Visible = False
Next
Application.ScreenUpdating = True
UserForm1.Show
Call ProWB
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Windows(Windows.Count).Visible = False
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)