hi all, am just curious to know...which is the better or more efficient way of these two?

Note: tblOD is a DataTable

For dtrows As Long = 0 To tblOD.Rows.Count - 1
         
          dgv1.Rows.Add(tblOD(dtrows)(0), tblOD(dtrows)(1), _
                        tblOD(dtrows)(2), _
                        tblOD(dtrows)(3), tblOD(dtrows)(4), _
                        tblOD(dtrows)(5), tblOD(dtrows)(6), _
                        tblOD(dtrows)(7))

        Next dtrows

OR

With tblOD
       For dtrows As Long = 0 To .Rows.Count - 1

          dgv1.Rows.Add(.Rows(dtrows)(0), .Rows(dtrows)(1), _
                        .Rows(dtrows)(2), _
                        .Rows(dtrows)(3), .Rows(dtrows)(4), _
                        .Rows(dtrows)(5), .Rows(dtrows)(6), _
                        .Rows(dtrows)(7))

        Next dtrows
    End With

Thank You!!!

Technically 2nd one.

there is not difference between those two except the fact that one of them is more readable because you used with [] statement

okay now i know...thanks so much for your help...

You should close the tread then

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.