Re: DateTime Error
Posted: Wednesday 13th March 2019 1:17pm
Again it work fine for me :-/
So the problem can coming from your system too.
So the problem can coming from your system too.
Thanks, I should have remembered that. Honestly, it's not all that often that I move controls around the form.
Dim d As DateBox
Dim s As String
d = New DateBox(Me)
d.Move(100, 100, 100, 20)
d.Show()
d.Value = CDate("01/01/2019")
s = CDate("01/01/2019")
d.Value = CDate(s)
Print s
Print d.Value
Print CFloat(CDate(s))
Print CFloat(d.Value)
Print CFloat(CDate(d.Value))
Output:
Code: Select all
01/01/2019
12/31/2018 00:00:00
2490589
2490588.16666667
2490588.16666667
d.Value = "01/01/2019"
Same result.
Dim t As String
Dim v As Date
Dim f As Float
Dim w As Date
v = CDate("01/01/2019")
t = Format(v, "mm/dd/yyyy")
f = Val(t)
w = f ' Implied CDate
Print v
Print CFloat(v)
Print CStr(v)
Print Str(v)
Print t
Print f
Print CDate(f)
Print w
Produces:Code: Select all
12/31/2018 20:00:00
2490589
01/01/2019
12/31/2018 20:00:00
12/31/2018
2490588.16666667
12/31/2018 00:00:00
12/31/2018 00:00:00
Private Function Value_Read() As Date
Dim vVal As Variant
If Not $bShowDate Then
vVal = Time(Val(Format(Date(1, 1, 1), "dd/mm/yyyy") & " " & $hButtonBox.Text))
Else
vVal = Val($hButtonBox.Text)
Endif
If vVal And If TypeOf(vVal) = gb.Date Then Return vVal
End
Private Sub Value_Write(Value As Date)
If IsNull(Value) Then
$hButtonBox.Text = GetNullDate()
Else
$hButtonBox.Text = Format(Value, GetDateFormat())
Endif
End
Private Sub GetDateFormat() As String
Dim sFormat As String
If $bShowDate Then
sFormat = Format(Date(3333, 11, 22), gb.ShortDate)
sFormat = Replace(sFormat, "3333", "yyyy")
sFormat = Replace(sFormat, "22", "dd")
sFormat = Replace(sFormat, "11", "mm")
Endif
If $bShowTime Then
sFormat &= " " & Format(Time(11, 22, 33), gb.ShortTime)
sFormat = Replace(sFormat, "11", "hh")
sFormat = Replace(sFormat, "22", "nn")
sFormat = Replace(sFormat, "33", "ss")
Endif
Return LTrim(sFormat)
End