Results 1 to 5 of 5

Thread: Listview Click Row

  1. #1
    Member
    Join Date
    Aug 12
    Posts
    42

    Listview Click Row

    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.

  2. #2

  3. #3
    Member
    Join Date
    Aug 12
    Posts
    42

    Re: Listview Click Row

    Quote Originally Posted by RhinoBull View Post
    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...

  4. #4
    PowerPoster
    Join Date
    Jul 06
    Location
    Maldon, Essex. UK
    Posts
    5,143

    Re: Listview Click Row

    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.
    Last edited by Doogle; Aug 19th, 2012 at 01:21 AM.

  5. #5
    Member
    Join Date
    Aug 12
    Posts
    42

    Re: Listview Click Row

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •