Ajouter un mot à la fin d'un nombre

Résolu
Utilisateur anonyme -  
 Utilisateur anonyme -
Bonjour, le forum
Je n’ai pas pu simplifier le code ci-dessous exemple faire boucle sur des nombres entiers qui indiquent l’ancienneté en ajoutant après chaque nombre saisi le mot « an » (pour 0 rien et pour 1 c’est « an ») pour le reste « ans » dans un textbox nommé f_ent13 ( ce textbox doit afficher exemple : 10 ans ou 1 an ou …)
Private Sub f_ent13_Change()
If f_ent13.Value = "" Then
f_ent13 = f_ent13 & ""
ElseIf f_ent13.Value = 1 Then
f_ent13 = f_ent13 & " an"
ElseIf f_ent13.Value = 2 Then
f_ent13 = f_ent13 & " ans"
Else
If f_ent13.Value = 3 Then
f_ent13 = f_ent13 & " ans"
End If
End If
End Sub

Merci d'avance
Cordialement

2 réponses

  1. cs_Le Pivert Messages postés 8437 Statut Contributeur 731
     
    Bonjour,

    s’effectue au doubleclic

    Option Explicit
    Private Sub f_ent13_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    Select Case f_ent13.Text
    Case Is = 0
    f_ent13.Text = f_ent13.Text & " an"
    Case Is = 1
    f_ent13.Text = f_ent13.Text & " an"
    Case Is > 1
    f_ent13.Text = f_ent13.Text & " ans"
    End Select
    End Sub
    
    

    1
  2. Utilisateur anonyme
     
    bonjour cs_Le pivert,
    Merci bien
    0