Avertir qu'un mot de passe a déjà été attribué à une autre personne
Bonjour,
Quelqu'un peut-il m'aider SVP ?
Je souhaite faire en sorte que lorsque j'introduis un nouveau mot de passe (+ confirmation) et que celui-ci fait partie de la liste qui se trouve dans le Sheet (11) range ("c3:c14"), un MsgBox annonce que le mot de passe a déjà été attribué à une autre personne. Dans le cas contraire, la procédure continue.
Voici mon codage.
Code:
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| Option Explicit
Dim maligne As Integer
Dim mon_mdp As String
Dim c
Dim fname 'Déclaration de la variable pour la voix
Dim objvoice As Object 'Déclaration de la variable pour la voix
Private Sub CommandButton5_Click()
mon_mdp = TextBox1.Text
With Worksheets(11).Range("C3:C14")
Set c = .Find(mon_mdp, LookIn:=xlValues)
If Not c Is Nothing Then
maligne = c.Row
Else
MsgBox " Mauvais ancien MOT DE PASSE !" _
& vbCrLf & vbCrLf & "***************************************************" _
& vbCrLf & vbCrLf & " NIEUW PASSWORD" _
& vbCrLf & vbCrLf & vbCrLf & " Slecht oud PASSWORD!" _
, vbCritical + vbOKOnly, " NOUVEAU MOT DE PASSE"
TextBox1 = ""
Exit Sub
End If
End With
If TextBox1 <> "" And TextBox2 <> "" And TextBox3 <> "" Then
If TextBox3.Text = TextBox2.Text Then
Worksheets(11).Range("C" & maligne).Value = TextBox2.Text
MotPasse.Hide
'Création du message vocal
Set objvoice = CreateObject("sapi.spvoice")
objvoice.Speak ("Your PASSWORD has been registered") 'texte fin de visite du fichier
MsgBox " Votre MOT DE PASSE a bien été enregistré !" _
& vbCrLf & vbCrLf & "***************************************************" _
& vbCrLf & vbCrLf & " NIEUW PASSWORD" _
& vbCrLf & vbCrLf & vbCrLf & " Uw PASSWORD is geregistreerd!" _
, vbInformation + vbOKOnly, " NOUVEAU MOT DE PASSE"
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
Else
MsgBox "Les 2 MOTS DE PASSE ne sont pas identiques !" _
& vbCrLf & vbCrLf & "***************************************************" _
& vbCrLf & vbCrLf & " NIEUW PASSWORD" _
& vbCrLf & vbCrLf & vbCrLf & " De 2 PASSWORDS zijn niet identiek!" _
, vbCritical + vbOKOnly, " NOUVEAU MOT DE PASSE"
'TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
End If
End If
End Sub |
Merci :lol:
McPOL