This is in connection with my last thread: http://www.vbforums.com/showthread.p...light-Due-Date
once I select or click a row with a due date value that is already pass, a message box will appear telling me how many days this due has passed.
Printable View
This is in connection with my last thread: http://www.vbforums.com/showthread.p...light-Due-Date
once I select or click a row with a due date value that is already pass, a message box will appear telling me how many days this due has passed.
To calculate number of days (weeks, months, etc) between two dates use DateDiff() function. Search fiorum if you need some sample code.
Hi RhinoBull,
Thanks for the reply. Yes I'm aware of the DateDiff() function. Problems is for example
Listview:
Invoice Due Date
Inv#A001 August 17, 2012
Inv#A003 September 5, 2012
Inv#A010 September 15, 2012
Inv#A023 September 17, 2012
This is what I want:
If invoice# A001 is selected a message will popup telling me this transaction is already due... If Invoice# A003 or A010 or A023 is selected nothing happens, because it is not yet due...
The simplest method, in your particular case, would be to test whether the due date subitem's colour is vbRed (or whatever colour you have used to higlight it) in the row the user has clicked on. As Rhino has pointed out, if you want to calculate the elapsed period, use the DateDiff Function.
Thanks guys, figured out the problems, here the code:
Code:
Private Sub ListView2_ItemClick(ByVal Item As MSComctlLib.ListItem)
'On Error Resume Next
Dim li As ListItem
Dim sol2
Dim dateValpass, getdateVal As Date
sol2 = ListView2.SelectedItem.Index
getdateVal = ListView2.ListItems.Item(sol2).SubItems(5)
If getdateVal < Now Then
dateValpass = DateDiff("d", getdateVal, Now())
MsgBox "Due date is already " & dateValpass & " days old"
End If
End Sub