Android Question DATE ERROR

RobRock92

Member
Licensed User
Longtime User
B4X:
Sub controlla(testo As String)
Dim gg,mm,aa As Long
Dim ris As String
Dim pos As Int

    DateTime.DateFormat = "dd/MM/yyyy"
   
    gg = testo.SubString2(0,2)
    mm = testo.SubString2(3,5)
    aa = testo.SubString2(6,10)
   

If gg < 1 OR gg > 31 Then
Msgbox2("GIORNO ERRATO","AVVISO","OK","","",Null)
    Else If mm <1 OR mm > 12 Then
Msgbox2("MESE ERRATO","AVVISO","OK","","",Null)
    Else If aa < 2012 OR aa > 2050 Then
Msgbox2("ANNO ERRATO","AVVISO","OK","","",Null)
    Else
    ris = gg & "/" & mm & "/" & aa
    End If
Return ris
End Sub


With this code I check the date in a string, but if I type, for example 04/05/2013 the result will be 4/5/2013....Why not put in the zero??
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…