title: vb.net loop through datarow and add each value into a listbox
body: <pre><code>Private Function ColumnEqual(ByVal A As Object, ByVal B As Object) As Boolean
    If A Is DBNull.Value AndAlso B Is DBNull.Value Then
      Return True 
    End If
  
    If A Is DBNull.Value OrElse B Is DBNull.Value Then
      Return False 
    End If
  
    Return A.Equals(B)
  End Function
  ...
  
  Public lastV As Object
  ...
  For Each dr In wData.Rows
    If lastV Is Nothing OrElse Not ColumnEqual(lastV, dr("table1")) Then
      ''check if first value is nothing
      If lastV = Nothing Then
        lastV = "00"
        l = "0"
      Else
        dr("t1") = lastV
        dr("n1") = l
      End If
      ListBox1.Items.Add(lastV &amp; " &lt;--&gt; " &amp; l)
      lastV = dr("table1")
      l = 1
    ElseIf lastV Is Nothing OrElse ColumnEqual(lastV, dr("table1")) Then
      l += 1
    End If
  Next
  </code></pre>
  
  <p>I use this code to loop through my <code>DataRow</code>.</p>
  
  <p>It adds each record into a <code>ListBox</code>, but it does not add the last record in the
  <code>DataRow</code> to the list.</p>
  
  <p>Any help?</p>