Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Getting some ListBox items

Hi!

I have this code and some data in listbox
Code
Dim attlist As New List(Of List(Of DateTime))
        For i = 0 To 30
            attlist.Add(New List(Of DateTime))

        Next
        For Each t As String In ListBox1.Items
            For i = 1 To 31
                If Convert.ToDateTime(t.Split(" "c)(0)).Month = i Then
                    attlist(i - 1).Add(t.Split(" "c)(0) & " " & t.Split(" "c)(t.Split(" "c).Length - 1))

                End If
            Next
        Next
        Dim p As Integer
        For i = 0 To 30
            If attlist(i).Count >= 2 Then
              

                Dim checkin, checkout As String

                checkin = ListBox1.Items(attlist(i).IndexOf(min(attlist(i))) + p)
                checkout = ListBox1.Items(attlist(i).IndexOf(max(attlist(i))) + p)
                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))
                ListBox2.Items.Add("On date " & ListBox1.Items(attlist(i).IndexOf(max(attlist(i))) + p).Split(" "c)(0) & " worked " & TOTALTIME.ToString("hh") & " hour e " + TOTALTIME.ToString("mm") & " minutes")



                p += attlist(i).Count
            End If
        Next

And I get this result witch is what I want
https://imgur.com/a/rtpCtS7

But this code is getting results only from date 1 to 12 and is working
If i add a date from 13 to 31 I get an error
https://imgur.com/a/2BfgPU5[

What I have to change to get this code work if I check for each day of the month from 1-31?
The month component, expressed as a value between 1 and 12
https://docs.microsoft.com/en-us/dotnet/...mework-4.8
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(Jun 11, 2019 09:06 AM)HFDone Wrote:  The month component, expressed as a value between 1 and 12
https://docs.microsoft.com/en-us/dotnet/...mework-4.8
Yes but how to change that part to express the days(1-31) and not the months(1-12)?Because I've tried .Day but I still get that error
https://docs.microsoft.com/en-us/dotnet/...mework-4.8
Convert.ToDateTime("11/6/2019").Day
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(Jun 11, 2019 10:51 AM)HFDone Wrote:  https://docs.microsoft.com/en-us/dotnet/...mework-4.8
Convert.ToDateTime("11/6/2019").Day
Yes now is working because what I was doing wrong was the format of the date...I had it like dd:mm:yyyy but after changed to mm:dd:yyyy now it works!


I have another thing that I want to do

To add another for cycle to get each name on the listbox any tip would be appriciated
you can grab it with your code t.Split(" "c)(1)
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by EffexionAug 18, 2017 04:02 AM 0 126 Aug 18, 2017 04:02 AM
Last Post: Effexion
[.NET] by GørillaFeb 28, 2017 07:24 AM 13 451 Feb 28, 2017 07:24 AM
Last Post: Gørilla
[.NET] by 270zDec 25, 2015 04:05 AM 6 209 Dec 25, 2015 04:05 AM
Last Post: Odus