# Visual Basic > Universal Windows Platform and Modern Windows Experience >  Compare DGV Row Value

## qulaitks

Good Day , H have Transactions DGV that holding Same Transaction ID for both type (Buy /Sell). This is on Cell(0)of the DGV. I want to highlight the transaction that bought but not sold , Cell(1) has the transaction type. I have tried the below cod but it is highlighting the whole rows. Please Help.


```
For i As Integer = 0 To DGV_Trans.Rows.Count - 2
            For j As Integer = i + 1 To DGV_Trans.Rows.Count - 2

                If DGV_Trans.Rows(i).Cells(0).Value <> DGV_Trans.Rows(j).Cells(0).Value Then
                    DGV_Trans.Rows(j).DefaultCellStyle.BackColor = Color.Green

                End If

            Next
        Next
```

----------


## Shaggy Hiker

It doesn't JUST highlight the row. There must be some error message. I can guess at what it is, but why don't you tell us. 

It's probably that you haven't looked at the types in the comparison.

----------


## qulaitks

there is no error message. I only want to check Cell(0) if the number is not repeated then highlight the row.

----------


## Shaggy Hiker

Have you stepped through the code? 

I just realized that I might have misunderstood your question. Would setting the color to green be highlighting or not highlighting? As long as that If statement is working (and the line inside the If statement is reached), then it seems like that should set the backcolor for the entire row to green. That would be a slightly odd highlight color, but if that IS the highlight color, then I'm not sure what problem you are trying to solve. 

I was thinking that you were comparing two Objects using <>, which won't work, but if the comparison is working, then those aren't type Object. Still, I can't decide whether you are saying that it's highlighting or not highlighting, whether it's highlighting too many rows, or the wrong rows, or shouldn't be highlighting the entire row. If green is the highlight, then what you are doing will highlight something, but it seems like it would highlight pretty nearly everything other than the final row (since you always go to count-2, you never check the final row). In fact, that code seems very likely to highlight every row aside from the first and the last every time, in which case it will also highlight nothing if there are only two rows, and sometimes would highlight nothing in other cases, as well. 

So, I guess the bottom line is that the way the question is written, you are assuming that we know thing about the design that only you know. We don't know what highlighting means. We don't know whether setting a backcolor to green is highlighting or not. We don't know whether there is a pattern to the data that makes it reasonable to skip the first and last rows. We don't know whether there's a pattern to the data such that the code won't end up just setting everything to green aside from the first and last rows. After all, you are comparing on inequality and talking about "the same transaction ID". If they are all unique, and the first line holds a value like "2", then all the other lines will not be "2", so they will all be turned green...and that's only after the first time through the outer loop. Basically, everything would be set to green unless all the values are the same. Is that what they should be? We certainly don't know, but you do.

----------


## bobbyrfletcher

it's hard to understand.

----------

