TextBox Format date

apdf1

XLDnaute Impliqué
Bonjour,

Pourriez vous me dire comment mettre le format date dans TextBox.
J'ai mis le code suivant et il sort le format comme ceci :40194 pour me donner "16/01/2010".
Code:
Private Sub UserForm_Initialize()
  Sheets("Feuil1").Select ' aller à la page active
Me.TextBox1.Value = UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex, 0) ' Ref
Me.TextBox3.Value = UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex, 1) ' Nom=

Me.TextBox4.Value = UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex, 2) ' Date
Me.TextBox7.Value = UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex, 6) ' Ville
Me.TextBox2.Value = UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex, 3) ' N° Ligne
Me.TextBox6.Value = UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex, 4) ' Adresse
Me.TextBox5.Value = UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex, 5) ' CP
Me.TextBox9.Value = UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex, 9) ' Mobile
Me.TextBox10.Value = UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex, 8) 'Fax
Me.TextBox8.Value = UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex, 7) 'Tel

Label151.Caption = " " & Range("B65536").End(xlUp).Row ' N° de la derniere ligne non vide


End Sub
Private Sub TextBox4_Change()
    If Len(TextBox4) = 2 Or Len(TextBox4) = 5 Then _
        TextBox4 = TextBox4 & "/"
End Sub

je m'explique j'ai un formulaire avec une listbox ou je DClick sur un item pour ouvrir un autre formulaire "fiche client" dans se deuxième formulaire ou userform comme on veut, j'ai des textbox donc un pour la date "TextBox4" et je n'arrive pas a obtenir une date normale.

Merci d'avance

Bien cordialement

Max
 
G

Guest

Guest
Re : TextBox Format date

Re,
bonjour Job:):):)

@apdf: 40194 au format date est le 16/01/2010

TextBoxX=Format(40194, "dd/mm/yyyy") affichera 16/01/2010

40194 peut être la valeur d' une variable (LaDate)
TextBoxX=Format(LaDate,"dd/mm/yyyy") affichera 16/01/2010 sir la variable 'LaDate' contient 40194

A+
 
Dernière modification par un modérateur:
G

Guest

Guest
Re : TextBox Format date

Re,

Alors il faut que tu postes ici un fichier reproduisant ton problème. Parce que là, ça est pas normal.

Petite précision il faut que 40190 soit un numérique et non une valeur textuelle. La convertir éventuellement avant.

A+
 

apdf1

XLDnaute Impliqué
Re : TextBox Format date

Re,

Voila j'ai mis mon fichier qui seras plus parlant, quand on ouvre premier formulaire on double click dans la listbox pour ouvrir le deuxième formulaire et on s'aperçois que la textbox date ne se met pas comme ("mm/dd/yyyy")

@+

Max
 

Pièces jointes

  • ListboxSuppriModif244.zip
    45.4 KB · Affichages: 49
G

Guest

Guest
Re : TextBox Format date

Re,

Où comment ne pas mettre en pratique.

Job75 t'avais donné une solution avec:

Code:
CDATE(UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex, 2))

Qui fonctionne très bien

Et moi avec
Code:
Format(Val(UserForm1.ListBox1.List(UserForm1.ListBox1.ListIndex, 2)), "mm/dd/yyyy")

Qui fonctionne également très bien.

A-
 

Discussions similaires

Réponses
17
Affichages
1 K

Statistiques des forums

Discussions
313 769
Messages
2 102 234
Membres
108 181
dernier inscrit
Chr1sD