1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Private Sub BtnOk_Click()
Dim Rech As Range
Dim ConfigUser As Byte
Static TentativePW As Byte, TentativeID As Byte
If NomUtilisateur = Empty Or PasseWord = Empty Then mess_01
Set Rech = Range("Users").Find(NomUtilisateur, LookIn:=xlValues, lookat:=xlWhole)
If Not Rech Is Nothing Then
If NomUtilisateur = Rech.Offset(0, 1) Then
ConfigUser = Rech.Offset(0, 2)
Autorisation ConfigUser
Else
TentativePW = TentativePW + 1
If TentativePW > 3 Then ThisWorkbook.Close 0
MsgBox "Mot de passe invalide, Tentative N° " & TentativePW & " Sur 3", vbCritical, "Sécurité Gestion parc"
With Me.PasseWord
.Value = ""
.SetFocus
End With
End If
Else
TentativeID = TentativeID + 1
If TentativeID > 3 Then ThisWorkbook.Close 0
MsgBox "Utilisateur inconnu, , Tentative N° " & TentativeID & " Sur 3", vbCritical, "Sécurité Gestion parc"
With Me.NomUtilisateur
.SetFocus
.SelStart = 0
.SelLength = Len(NomUtilisateur.Text)
End With
End If
End Sub |
Partager