-
Mar 12th, 2015, 10:11 AM
#1
Thread Starter
Junior Member
[RESOLVED] Rowcount particular value
Hi vbforum users!
I need to rowcount in datagridview with a particular value.
My column "6" have the value that find, I try with the following code:
Code:
Dim apc As Decimal = 0
For x As Integer = 0 To DataGridView3.RowCount - 1
If DataGridView3.Rows(x).Cells(6).Value = "AP" Then
apc = DataGridView3.Rows(x).Cells(6).Value.ToString.Count
End If
Next
textbox1.text=apc
any help, as welcome!!
Best Regards!!
-
Mar 12th, 2015, 10:26 AM
#2
Re: Rowcount particular value
Are you trying to get the sum of the values in column 6, or just the count of the number of rows that have the given value?
If the former, then the line above would look like:
vb Code:
apc += DataGridView3.Rows(x).Cells(6).Value
If the latter, then you would simply say:
I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
Mar 12th, 2015, 11:06 AM
#3
Thread Starter
Junior Member
Re: Rowcount particular value
Great Dolot! Best Regards!
Code:
For x = 0 To DataGridView3.Rows.Count - 1
If DataGridView3.Rows(x).Cells(6).Value = "AP" Then
count += 1
End If
Next
-
Mar 12th, 2015, 11:43 AM
#4
Re: Rowcount particular value
How exactly is the datagridview being populated? Is there a datatable attached to it, or is it just user input?
I always add to the reputation of those whose posts are helpful, and even occasionally to those whose posts aren't helpful but who obviously put forth a valiant effort. That is, when the system will allow it.
My war with a browser-redirect trojan
-
Mar 14th, 2015, 12:44 PM
#5
Thread Starter
Junior Member
Re: Rowcount particular value
Hi Sr!
Only populate the textbox
Code:
For x = 0 To DataGridView3.Rows.Count - 1
If DataGridView3.Rows(x).Cells(6).Value = "AP" Then
count += 1
End If
Next
textbox1.text=count
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|