我被困在寻找
我的桌子是:
Passenger | Destination | Status
23 | Mars | PWD
我可以在第3列上找到PWD的值,但无法在第3列具有PWD值的第1列上乘以PWD。
这是我用于查找PWD值的代码:
For a As Integer = 0 To DataGridView1.Rows.Count - 1
If (DataGridView1.Rows(a).Cells(2).Value IsNot DBNull.Value Or Trim(DataGridView1.Rows(a).Cells(2).Value <> Nothing) AndAlso DataGridView1.Rows(a).Cells(2).Value = "PWD") Then
PWD = PWD + 1
End If
Next
Dim pwdcount = (From row As DataGridViewRow In DataGridView1.Rows _
Where row.Cells("Status").Value = "PWD" And row.Cells("Status").Value IsNot DBNull.Value _
Select row.Cells("Status").Value).Count()
label1.text = "The number of PWD is : " & pwdcount
我认为您可能正在尝试找到LINQ解决方案,这不是我在下面建议的。但是我相信这会满足您的要求...
Dim pwdcount As Integer
For Each oRow As DataGridViewRow In DataGridView1.Rows
Dim oPassengerCell As DataGridViewCell = oRow.Cells("Passenger")
Dim oStatusCell As DataGridViewCell = oRow.Cells("Status")
If IsNumeric(oPassengerCell.Value) AndAlso oStatusCell.Value = "PWD" Then
pwdcount += oPassengerCell.Value
End If
Next
Label1.Text = "The number of PWD is : " & pwdcount
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句