Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15702

VS 2019 Counting rows with the same date as 1 item.

$
0
0
Hello!

I have a table with a column called: "DGV_Date_Column", it contains the dates of my sale tickets. I've sent these values to a DataGridView1 and I'm trying to display de total amount of tickets in a Label1.Text. I mean all rows with the same date and time belong to a single ticket, so in the image I show 3 tickets total, and I need to display this total in the Label1.Text

this is what my table looks like:
Name:  image20.jpg
Views: 57
Size:  31.8 KB

This is my attempt to do it, but no success.

VB.NET Code:
  1. If DataGridView1.Rows.Count <= 0 Then
  2. Else
  3. Dim number_of_tickets As Integer = 0
  4. Dim Date_and_Time As String = ""
  5. For Each row1 As DataGridViewRow In DataGridView1.Rows
  6.     Date_and_Time = row1.Cells("DGV_Date_Column").Value
  7.     If row1.Cells("DGV_Date_Column").Value <> Date_and_Time Then
  8.         number_of_tickets += 1
  9.     Else
  10.     End If
  11. Next
  12.  Label1.Text = number_of_tickets
  13. End If

I'll appreciate any help.

Thank you.
Attached Images
 

Viewing all articles
Browse latest Browse all 15702

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>