MsgBox avec condition

Résolu
Bourrique66 Messages postés 166 Statut Membre -  
Bourrique66 Messages postés 166 Statut Membre -

Private Sub TextBox33_Change()
Application.ScreenUpdating = False
TextBox33.Value = Format(TextBox33.Value, "0 Mois")

           Dim test As Boolean
With TextBox33
    test = Val(Replace(.Text, ",", ".")) >= 6
    .BackColor = IIf(test, vbRed, vbGreen)
    .ForeColor = IIf(test, vbWhite, vbBlack)
    .Font.Bold = test
End With

    If Me.TextBox33.Value >= 6 Then
  MsgBox "Attention produit anti-crevaison route dépassé"
  End If

Application.ScreenUpdating = True
End Sub

4 réponses

via55 Messages postés 14730 Date d'inscription   Statut Membre Dernière intervention   2 750
 

Bonjour

Essaie ainsi

Private Sub TextBox33_Change()
If Right(TextBox33.Value, 1) = "s" Then Exit Sub
Application.ScreenUpdating = False
TextBox33.Value = Format(TextBox33.Value, "0 Mois")
           Dim test As Boolean
With TextBox33
    test = Val(Replace(.Text, ",", ".")) >= 6
        If test = True Then MsgBox "Attention produit anti-crevaison route dépassé"
    .BackColor = IIf(test, vbRed, vbGreen)
    .ForeColor = IIf(test, vbWhite, vbBlack)
    .Font.Bold = test
End With

Application.ScreenUpdating = True
End Sub

Cdlmnt

Via


0
Bourrique66 Messages postés 166 Statut Membre 2
 

Merci Via ;

votre code fonctionne parfaitement, si vous avez le temps pourriez-vous mettre des commentaires dans votre code afin que je puisse le comprendre pour pouvoir le reproduire. Bien sûr si vous avez le temps. Merci de votre patience

0
via55 Messages postés 14730 Date d'inscription   Statut Membre Dernière intervention   2 750
 

Le code est le tien

J'ai seulement modifié 2 choses

 TextBox33Value      


0
Bourrique66 Messages postés 166 Statut Membre 2
 

Bonjour Via

Merci d'avoir pris du temps pour me répondre 

0