hello
sir
getting error when run the loop and going to last value of row count
please help

and i can not use the 2nd loop in the place of cells(?????) number how can i use this

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

What I have tried:***

Dim aa As Integer
       For Z1 = 0 To DataGridView1.RowCount

           If Me.DataGridView1.Rows(Z1).Cells(2).Value = True Then
               aa = 1
           Else
               aa = 0
           End If
           Me.DataGridView1.Rows(Z1).Cells(7).Value = aa
           If Me.DataGridView1.Rows(Z1).Cells(3).Value = True Then
               aa = aa & 1
           Else
               aa = aa & 0
           End If
           Me.DataGridView1.Rows(Z1).Cells(7).Value = aa
           If Me.DataGridView1.Rows(Z1).Cells(4).Value = True Then
               aa = aa & 1
           Else
               aa = aa & 0
           End If
           Me.DataGridView1.Rows(Z1).Cells(7).Value = aa
           If Me.DataGridView1.Rows(Z1).Cells(5).Value = True Then
               aa = aa & 1
           Else
               aa = aa & 0
           End If
           Me.DataGridView1.Rows(Z1).Cells(7).Value = aa
           If Me.DataGridView1.Rows(Z1).Cells(6).Value = True Then
               aa = aa & 1
           Else
               aa = aa & 0
           End If
           Me.DataGridView1.Rows(Z1).Cells(7).Value = aa
       Next

Try

For Z1 = 0 To DataGridView1.RowCount - 1

If you have 5 rows, for example, the indices are 0, 1, 2, 3, 4

commented: "Hey that's my luggage combination" - Programmer President Skroob. +15
commented: thanks sir +2
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.