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?

Recommended Answers

All 4 Replies

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.

thanks but am working on listview.

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
commented: For the effort showed here. +7

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.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.