Hi group, I have another problem with these “damned” datetimes. I would like to read in the PaintCellBackground of a listbox the date value stored in a cell for all the rows of the listbox and compare it with the current date. If the date read is greater than the current date, color the line red.
My code return error in DataRead=DateTime.FromString(convertedDate), Parse error: date needs to be in the format of YYYY-MM-DD HH:MM or YYYY-MM-DD …
Is there a way to set the format directly on this staff?
Dim convertedDate as String
Dim fieldY, fieldD, fieldM as String
Dim DataRead,DataNow as date
'Read in format dd/mm/YYYY
if listboxingressi.CellTextAt(row,6)<>"" then
convertedDate=listboxingressi.CellTextAt(row,6)
else
convertedDate=""
end if
DataRead=DateTime.FromString(convertedDate)
// THIS FUNCTION CONVERTS THE SQLDATE INPUT TO THE D/M/Y FORMAT
// AND REASSEMBLE DATE IN FORMAT DD/MM/YYYY
convertedDate = DateTime.Now.SQLDate
fieldY = convertedDate.NthField("-",1)
fieldM = convertedDate.NthField("-",2)
fieldD = convertedDate.NthField("-",3)
convertedDate = fieldD+"/"+fieldM+"/"+fieldY
messagebox " Oggi è la data ..:" + convertedDate
DataNow=DateTime.FromString(convertedDate)
if DataNow>DataRead then
g.DrawingColor= &cff1100 ' rosso acceso
g.FillRectangle(0, 0, g.Width, g.Height)
else
if row Mod 2 = 0 Then
g.DrawingColor= &cf0ffff ' celestino CHIARO
Else
g.DrawingColor= &cFFFFFF 'BIANCO
End If
g.FillRectangle(0, 0, g.Width, g.Height)
end if