Bonjour,
Voilà le code dont je me sers.
Dans Caption du Label1 : @
Private Sub TextBox1_Change() ' Mail
TextBox1.Text = LCase(TextBox1)
Dim S As String
S = Me.TextBox1.Value
If InStr(1, S, "@") > 0 And InStr(1, S, ".") Then
Me.TextBox1.ForeColor = rgb(0, 0, 255)
Me.TextBox1.Font.Underline = True
Label1.Visible = True ' Affiche le label
Else ' Sinon
Me.TextBox1.ForeColor = &H80000008
Me.TextBox1.Font.Underline = False
Label1.Visible = False ' Masque le label
End If ' Fin de la condition
End Sub
'**** Correspond au format de la TextBox1 "Adresse @Mail" ****
Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) ' Mail
Dim S As String
S = Me.TextBox1.Value
If InStr(1, S, "@") > 0 And InStr(1, S, ".") > 0 Then
ThisWorkbook.FollowHyperlink "mailto: " & Me.TextBox1.Value
End If ' Fin de la condition
End Sub
'**** Correspond à la validation de la TextBox1 "Adresse @Mail" ***
Private Sub TextBox1_AfterUpdate()
If TextBox1 <> Empty Then
If InStr(1, TextBox1, "@") = 0 Then
Reponse = MsgBox("l'adresse E.mail doit contenir un @ !", vbExclamation + vbOKOnly, "Merçi")
TextBox1 = Empty
TextBox1.SetFocus
Exit Sub
End If
End If
End Sub
Cordialement