1,、界面包括用戶名、密碼,,可以修改用戶名和密碼 2,、在修改用戶名和密碼的時(shí)候需要輸入原來的用戶名和密碼,該用戶名和密碼存放在excel自帶的名稱管理器中,,可以實(shí)現(xiàn)更新 3,、用戶名或者密碼輸入錯(cuò)誤3次即提示輸入錯(cuò)誤而退出,無(wú)權(quán)打開該excel表格 4,、輸入了正確的用戶名和密碼后會(huì)看到歡迎提示框 主要代碼如下: Sub NameVisible() Names('username').Visible = False Names('userword').Visible = False End Sub Private Sub Workbook_Open() Application.Visible = False denglu.Show MsgBox '歡迎登錄寧子工作室,!' End Sub Private Sub cmd1_Click() Application.ScreenUpdating = False Static i As Integer If CStr(t1.Value) = Right(Names('UserName').RefersTo, Len(Names('UserName').RefersTo) - 1) And CStr(t2.Value) = Right(Names('UserWord').RefersTo, Len(Names('UserWord').RefersTo) - 1) Then Unload Me Application.Visible = True Else i = i 1 If i = 3 Then MsgBox '對(duì)不起,你無(wú)權(quán)打開工作簿,!', vbInformation, '提示' ThisWorkbook.Close savechanges:=False Else MsgBox '輸入錯(cuò)誤,,你還有' & (3 - i) & '次輸入機(jī)會(huì)', vbExclamation, '提示' t1.Value = '' t2.Value = '' End If End If Application.ScreenUpdating = True End Sub Private Sub cmd2_Click() Unload Me ThisWorkbook.Close savechanges:=False End Sub Private Sub cmd3_Click() Dim old As String, new1 As String, new2 As String old = InputBox('請(qǐng)輸入原用戶名:', '提示') new1 = InputBox('請(qǐng)輸入新用戶名:', '提示') new2 = InputBox('請(qǐng)?jiān)俅屋斎胄掠脩裘?, '提示') If old <> '' And new1 <> '' Then If old = Right(Names('UserName').RefersTo, Len(Names('UserName').RefersTo) - 1) And new1 = new2 Then Names('UserName').RefersTo = '=' & new1 ThisWorkbook.Save MsgBox '用戶名修改完成,下次登錄請(qǐng)使用新用戶名', vbInformation, '提示' Else MsgBox '輸入錯(cuò)誤,,修改沒有完成', vbCritical, '錯(cuò)誤' End If Else MsgBox '用戶名不能為空', vbCritical, '錯(cuò)誤' End If
End Sub Private Sub cmd4_Click() Dim old As String, new1 As String, new2 As String old = InputBox('請(qǐng)輸入原密碼:', '提示') new1 = InputBox('請(qǐng)輸入新密碼:', '提示') new2 = InputBox('請(qǐng)?jiān)俅屋斎胄旅艽a:', '提示') If old <> '' And new1 <> '' Then If old = Right(Names('UserWord').RefersTo, Len(Names('UserWord').RefersTo) - 1) And new1 = new2 Then Names('UserWord').RefersTo = '=' & new1 ThisWorkbook.Save MsgBox '用戶密碼修改完成,下次登錄請(qǐng)使用新密碼', vbInformation, '提示' Else MsgBox '輸入錯(cuò)誤,,修改沒有完成', vbCritical, '錯(cuò)誤' End If Else MsgBox '密碼不能為空', vbCritical, '錯(cuò)誤' End If End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) If CloseMode <> 1 Then Cancel = 1 End Sub |
|