Italian Date Select

Nikeddy

Active Member
Licensed User
Longtime User
Salve,

ma esiste il modo per far uscire, in un campo, un calendario, cosi da segnalare la data?

mi serve perché sto creando un semplice form ma per la data mi sto impiccando....
 

LucaMs

Expert
Licensed User
Longtime User
Hai provato a scrivere il titolo che hai messo qui nella casella per la ricerca e premere Invio?

upload_2017-3-17_14-35-14.png
 

Nikeddy

Active Member
Licensed User
Longtime User
si ma parla di un datepicker ma e' molto molto complicato!
non c'e' un semplice modo?
 

MarcoRome

Expert
Licensed User
Longtime User
B4X:
    Dim retdata, rettempo As Int

    Dim Dd As DateDialog
    Dd.ShowCalender = False
    Dd.Year = DateTime.GetYear(DateTime.Now)
    Dd.Month = DateTime.GetMonth(DateTime.Now)
    Dd.DayOfMonth = DateTime.GetDayOfMonth(DateTime.Now)
    retdata = Dd.Show("Simply choose the date and time you'd like Schedule", "Date Schedule", "Yes", "", "Cancel", Null)
    'ToastMessageShow(retdata & " : " & Dd.DayOfMonth & "/" & Dd.Month & "/" & Dd.Year , False)
    If retdata = DialogResponse.POSITIVE Then
        Dim td As TimeDialog
        td.Hour = DateTime.GetHour(DateTime.Now)
        td.Minute = DateTime.GetMinute(DateTime.Now)
        td.Is24Hours = True
        rettempo = td.Show("Set the Required Time ", "Service Timer", "Yes", "", "Cancel", Null)
        'ToastMessageShow(rettempo & " : " & td.Hour & ":" & td.Minute, False)
      ...............   
               
        End If
           
    End If
 

Star-Dust

Expert
Licensed User
Longtime User
Piccola modifica ;)

B4X:
    Dim DataSelect, TimeSelect As Int

    Dim Dd As DateDialog
    Dd.ShowCalendar = False
    Dd.DateTicks= DateTime.Now
 
    Dim td As TimeDialog
    td.DateTicks=DateTime.Now
 
    DataSelect = Dd.Show("Simply choose the date and time you'd like Schedule", "Date Schedule", "Yes", "", "Cancel", Null)
 
    If DataSelect = DialogResponse.POSITIVE Then
        td.Is24Hours = True
        TimeSelect = td.Show("Set the Required Time ", "Service Timer", "Yes", "", "Cancel", Null)
        'ToastMessageShow(rettempo & " : " & td.Hour & ":" & td.Minute, False)
        If TimeSelect = DialogResponse.POSITIVE Then
            'Data accettata
        End If
    End If
 
Last edited:

Nikeddy

Active Member
Licensed User
Longtime User
ahahahahah
aspetta spiegami come funziona

io metto un campo testo e cliccando lui apre il calendario?
 

Star-Dust

Expert
Licensed User
Longtime User
Più o meno si. Dichiari la variabile DataDialog con un bel DIM

All'interno della Variabile/Oggetto ci sono dei campi che riempirai con i valori che vuoi.

Ad esempio un valore importante da specificare è la data iniziale, che inserisci come ha fatto MarcoRome, giorno ; mese; Anno.
B4X:
Dd.Year = DateTime.GetYear(DateTime.Now)
Dd.Month = DateTime.GetMonth(DateTime.Now)
Dd.DayOfMonth = DateTime.GetDayOfMonth(DateTime.Now)

Oppure come faccio io con un numero di tipo LONG (sarebbe una data completa giorno;mese;anno;ora;minuti;secondi in un solo numero di tipo LONG). Datetime.now é il valore long del preciso instante di quando lo richiami (Spero che conosci almeno il DATETIME)
B4X:
td.DateTicks=DateTime.Now

Puoi scegliere se far vedere il calendario con tutti i del mese o solo la data singola con
B4X:
Dd.ShowCalendar = False ' Non si apre il calendario
Dd.ShowCalendar = True ' Si apre il calendario

Poi usi il metodo Show, che restituisce la scelta che hai fatto in formato LONG (TimePicker pe rintenderci)
B4X:
DataSelect = td.Show("Scegli la data ", "CALENDARIO", "Confermo", "", "Annulla", Null)

da quello con i metodi di DATETIME puoi ricavarti giorno,mese,anno
B4X:
Giorno=DateTime.GetDayOfMonth(td.DateTicks)

cmq a quel link trovi tutto
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Sulla variabile di risposta del metodo Show (DataSelect nel'esempio) ottieni un valore che dice cosa hai cliccato. Conferma, Annulla o Cancella

B4X:
if DataSelect= DialogResponse.POSITIVE Then
' ha CONFERMATO
else if TimeSelect = DialogResponse.NEGATIVE Then
' Negative
else if TimeSelect = DialogResponse.CANCELThen
'Cancel
END IF
 
Top