A
ai1231
Guest
Hi!
I have a listbox with data like this(shown also in photo attached)
10/06/2019 Hyrja xxx yyy 08:51:00
10/06/2019 Dalja xxx yyy 12:58:50
10/06/2019 Hyrja xxx yy 13:32:40
11/06/2019 Hyrja xxx yyy 08:32:40
11/06/2019 Hyrja xxx yyy 13:32:40
11/06/2019 Hyrja xxx yyy 13:32:40
11/06/2019 Hyrja Ilda Ndreu 17:32:40
What I want to do is loop through all listbox items and check for each date of the month if that date is on listbox get for each date the first and the last item
So the result I want to get in this case is:
10/06/2019 Hyrja xxx yyy 08:51:00
10/06/2019 Hyrja xxx yyy 13:32:40
11/06/2019 Hyrja xxx yyy 08:32:40
11/06/2019 Hyrja xxx yyy 17:32:40
I have olso some code but I'm not getting what I want
For i As Integer = CInt(DateTimePicker1.Value.ToString("dd")) To CInt(DateTimePicker2.Value.ToString("dd"))
For l_index As Integer = 0 To ListBox1.Items.Count - 1
If CStr(ListBox1.Items(l_index)).ToString.Contains(TextBox2.Text) And CStr(ListBox1.Items(l_index)).ToString.Contains(i.ToString("d2") & DateTimePicker1.Value.ToString("/MM/yyyy")) Then
Dim checkin, checkout As String
checkin = CStr(ListBox1.Items(l_index))
checkout = ListBox1.Items(ListBox1.Items.Count - 1).ToString
MsgBox(CStr(ListBox1.Items(l_index)) & ListBox1.Items(ListBox1.Items.Count - 1).ToString)
Dim timestart, timeend As String
timestart = checkin.Substring(checkin.LastIndexOf(" "))
timeend = checkout.Substring(checkin.LastIndexOf(" "))
Dim ENDTIME As Date
Dim STARTTIME As Date
STARTTIME = timestart
ENDTIME = timeend
Dim TOTALTIME As TimeSpan
TOTALTIME = TimeSerial(Hour(ENDTIME), Minute(ENDTIME), Second(ENDTIME)) - TimeSerial(Hour(STARTTIME), Minute(STARTTIME), Second(STARTTIME))
MsgBox("me date: " & i.ToString("d2") & DateTimePicker1.Value.ToString("/MM/yyyy") & " ka punuar " & TOTALTIME.ToString("hh") & " ore e " + TOTALTIME.ToString("mm") & " minuta")
End If
Next
Next
Continue reading...
I have a listbox with data like this(shown also in photo attached)
10/06/2019 Hyrja xxx yyy 08:51:00
10/06/2019 Dalja xxx yyy 12:58:50
10/06/2019 Hyrja xxx yy 13:32:40
11/06/2019 Hyrja xxx yyy 08:32:40
11/06/2019 Hyrja xxx yyy 13:32:40
11/06/2019 Hyrja xxx yyy 13:32:40
11/06/2019 Hyrja Ilda Ndreu 17:32:40
What I want to do is loop through all listbox items and check for each date of the month if that date is on listbox get for each date the first and the last item
So the result I want to get in this case is:
10/06/2019 Hyrja xxx yyy 08:51:00
10/06/2019 Hyrja xxx yyy 13:32:40
11/06/2019 Hyrja xxx yyy 08:32:40
11/06/2019 Hyrja xxx yyy 17:32:40
I have olso some code but I'm not getting what I want
For i As Integer = CInt(DateTimePicker1.Value.ToString("dd")) To CInt(DateTimePicker2.Value.ToString("dd"))
For l_index As Integer = 0 To ListBox1.Items.Count - 1
If CStr(ListBox1.Items(l_index)).ToString.Contains(TextBox2.Text) And CStr(ListBox1.Items(l_index)).ToString.Contains(i.ToString("d2") & DateTimePicker1.Value.ToString("/MM/yyyy")) Then
Dim checkin, checkout As String
checkin = CStr(ListBox1.Items(l_index))
checkout = ListBox1.Items(ListBox1.Items.Count - 1).ToString
MsgBox(CStr(ListBox1.Items(l_index)) & ListBox1.Items(ListBox1.Items.Count - 1).ToString)
Dim timestart, timeend As String
timestart = checkin.Substring(checkin.LastIndexOf(" "))
timeend = checkout.Substring(checkin.LastIndexOf(" "))
Dim ENDTIME As Date
Dim STARTTIME As Date
STARTTIME = timestart
ENDTIME = timeend
Dim TOTALTIME As TimeSpan
TOTALTIME = TimeSerial(Hour(ENDTIME), Minute(ENDTIME), Second(ENDTIME)) - TimeSerial(Hour(STARTTIME), Minute(STARTTIME), Second(STARTTIME))
MsgBox("me date: " & i.ToString("d2") & DateTimePicker1.Value.ToString("/MM/yyyy") & " ka punuar " & TOTALTIME.ToString("hh") & " ore e " + TOTALTIME.ToString("mm") & " minuta")
End If
Next
Next
Continue reading...