Question: I have a DataTable that contains 4 rows. I want to compare a value in one column in row 1 with the value in row 2. Something similar to this:

```
For Each row As DataRow in drRows
  If row("column") <> row("column") 'I want the second row("column") to be the next row.
     'do something else
  End If
Next

```

Answer: 
You keep track of the last item:

```
Dim last As DataRow = Nothing

For Each row As DataRow In drRows
    If last IsNot Nothing Then
        ' Compare last with row
    End If

    last = row
Next

```
Say you have the following table:

```none
A   B    C   D
1   2    3   4
5   6    7   8 
9   10   11  12
12  12   13  14

```

```
For i As Integer = 0 To dt.Rows.Count - 2
   If dt.Rows(i)("ColName") <> dt.Rows(i + 1)("ColName") Then    
       'Do something
   End If
Next

```