Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

Help with simplifying For Next loop for multiple Grids

Hello,


How do I modify the code to avoid writing the same code for multiple Grids (C1Screen1,C1Screen2,C1Screen3)?

For i = 0 To Me.C1Screen1.Rows.Count - 1
            For j = 1 To Me.C1Screen1.Columns.Count - 1
                 If Me.C1Screen1.Rows(i).Cells(j).Value = "" Then 
                    Me.C1Screen1.Rows(i).Cells(j).Style.BackColor = Color.Red
                 End If
            Next
        Next

Open in new window

SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Victor  Charles

ASKER

Hi,

Is it possible to use this approach and replace Me.C1Screen1 with curXYZ ?

Dim xyz() As String = New String() {"c1screen1", "c1screen2", "c1screen3"}
Dim curXYZ = xyz(i)
For i = 0 To 2
For i = 0 To Me.C1Screen1.Rows.Count - 1
            For j = 1 To Me.C1Screen1.Columns.Count - 1
                 If Me.C1Screen1.Rows(i).Cells(j).Value = "" Then 
                    Me.C1Screen1.Rows(i).Cells(j).Style.BackColor = Color.Red
                 End If
            Next
        Next

Next

Open in new window


Thanks,

V.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you, will try it and get back to you.