French utilisation des dates sur B4A

Tata Mapassa

Member
Licensed User
Longtime User
Bonjour,

Comment faire pour récupérer une date saisie dans EditText et afficher à partir d'un label cette date + 2 jours ?
Par exemple, date saisie 25/03/2017 - date affichée 27/03/2017.
Merci
 

udg

Expert
Licensed User
Longtime User
Hi GOMBE.
try something like the following:
B4X:
Dim EditDate as long = DateTime.DateParse(Edit1.Text) 'pay attention to DateFormat
Dim DayAfterTomorrow As Long = DateTime.Add(EditDate , 0, 0, 2)
Dim MyLabel as Label
MyLabel.Text = DateTime.Date(DayAfterTomorrow)

udg
 

Tata Mapassa

Member
Licensed User
Longtime User
voici mon code :
Dim EditDate As Long = DateTime.DateParse(EditText1.Text) 'avec dd/mm/aaaa
Dim DayAfterTomorrow As Long = DateTime.Add(EditDate , 0, 0, 2)
Label1.Text = DateTime.Date(DayAfterTomorrow)
 

imbault

Well-Known Member
Licensed User
Longtime User
Just add before your code :
B4X:
DateTime.DateFormat= ="dd/MM/yyyy"

And Klaus is right MM must be uppercase, else it's for minutes no month
 

klaus

Expert
Licensed User
Longtime User
J'ai l'impression que tu te fous de nous.
Ci-dessous un petit projet qui fonctionne!!!
C'est frustrant que les personnes qui aident doivent prouver ce qu'elles conseillent.
B4X:
Sub Button1_Click
    DateTime.DateFormat = "dd/MM/yyyy"
    Dim EditDate As Long = DateTime.DateParse(EditText1.Text) 'avec dd/mm/aaaa
    Dim DayAfterTomorrow As Long = DateTime.Add(EditDate , 0, 0, 2)
    Label1.Text = DateTime.Date(DayAfterTomorrow)
End Sub
 

Attachments

  • TestTime.zip
    7.8 KB · Views: 407
Top