I am creating a program for television shows/programs. everything works fine...time taken by a particular program, total time wasted in a day, week and used in day, week, specific hours etc.

i am having problem during data entry. after the user clicks "Add Program", it is added to a listview. my problem now is this:

say the user enters starting time of a program to be 8:00, and next program at 9:00...after all are added, he may enter 7:30 or 7:45. i need this hour to be added before 8:00 in the listview. so far my codes haven't been able to search for the right "position" to place it in the listview.

any idea please?

7 Years
Discussion Span
Last Post by AndreRet

Try storing an integer containing yymmddhhmm in the ItemData for each ListView entry. It's clunky but it works. Just search down the ItemData until you find the index you want, then

listview.additem "youritem", indexYouFound  
listview.itemdata(listview.newindex) = yymmddhhmm.

Oh, and be sure to use 24-hr clock settings instead of 12-hr.

Edited by BitBlt: Added note after code.


Oh, I finally got the solution:

Private Sub InsertProgramTime(ByVal pgt As String)
Dim looper3 As Integer
Dim cnt As Integer
cnt = lvtt.ListItems.Count
If cnt = 0 Then
programposition = 1
Exit Sub
End If

For looper3 = 1 To lvtt.ListItems.Count

   If DateDiff("s", lvtt.ListItems(looper3).ListSubItems(1).Text, pgt) < 0 Then

   programposition = looper3
   Exit Sub
   Exit For

   End If
Next looper3
programposition = lvtt.ListItems.Count + 1

End Sub

Edited by mike_2000_17: Fixed formatting

Votes + Comments
For the effort showed here.

Nice in solving this yourself. Some "kudos" for your effort.

Please mark this as solved, found at the bottom of this page "Is this thread solved?", thanks.:)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.