Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Format date dans TextBox

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

Evelynetfrancois

XLDnaute Impliqué
BONJOUR a tous !!!
Voici mon soucis !!!

comme ça ,ça fonctionne bien !

Private Sub UserForm_Initialize()
TextBox3.Value = date
End Sub

Private Sub SpinButton1_SpinUp()
TextBox3 = CDate(DateValue(TextBox3) + 1)
End Sub

Private Sub SpinButton1_SpinDown()
TextBox3 = CDate(DateValue(TextBox3) - 1)
End Sub

Mais comme ça ,ça bug ??
Pouvez-vous m aider à combattre mon erreur !!!

Private Sub UserForm_Initialize()
TextBox3.Value = Format(Date, "dddd dd mmmm ")"""pour avoir l affichage du TexBox3 ,style.... lundi 17 juillet""""
End Sub

Private Sub SpinButton1_SpinUp()
TextBox3 = CDate(DateValue(TextBox3) + 1)
End Sub

Private Sub SpinButton1_SpinDown()
TextBox3 = CDate(DateValue(TextBox3) - 1)
End Sub

j espere etre clair ????
Merci d avance à toutes et tous

E et F
 
Re : Format date dans TextBox

Bonsoir Evelynetfrancois, le Forum,

Comme ton TextBox contient une chaine de caractères au format "dddd dd mmmm ", c'est la fonction DateValue() qui ne passe pas, car VBA ne reconnait pas cette chaîne comme une date et ne peut donc l'évaluer.

Tu peux contourner le problème simplement en appliquant la méthode ci-dessous (se servir de la propriété Tag du TextBox pour "stocker" la vraie valeur de date) :

Code:
[SIZE=2]Private [COLOR=navy]Sub[/COLOR] UserForm_Initialize()
      [B]TextBox3.Tag = [COLOR=navy]Date[/COLOR]
[/B]      TextBox3.Value = Format([COLOR=navy]Date[/COLOR], "dddd dd mmmm")
[COLOR=navy]End Sub[/COLOR]

[COLOR=navy]Private Sub[/COLOR] SpinButton1_SpinUp()
      [COLOR=navy]With[/COLOR] TextBox3
            [B].Tag = [COLOR=navy]Date[/COLOR]Value(.Tag) + 1
[/B]            .Value = Format([B].Tag[/B], "dddd dd mmmm")
      [COLOR=navy]End With
End Sub[/COLOR]

[COLOR=navy]Private Sub[/COLOR] SpinButton1_SpinDown()
      [COLOR=navy]With[/COLOR] TextBox3
            [B].Tag = [COLOR=navy]Date[/COLOR]Value(.Tag) - 1
[/B]            .Value = Format([B].Tag[/B], "dddd dd mmmm")
      [COLOR=navy]End With
End[/COLOR] Sub[/SIZE]
Cordialement,
 
Re : Format date dans TextBox

MERCI beaucoup myDearFriend! SUPER !!!

ca c' est sur je pouvais toujours essayer de "tourner " des tas de trucs !!!
je n4aurais jamais trouvé !!!!un truc pareil !!
merci pour tout et bonne soirée a toi !!
E et F
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
4
Affichages
230
Réponses
3
Affichages
430
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…