VB6 - Delete row if specific cell in Grid have a specific color

Hi.

I would like to know how i can delete all rows of my MSHFlexgrid1 that are not with a back color: &H80FF& in column 1.

How can i do that please?

Thanks

  Dim i As Long
    For i = MSHFlexGrid1.Rows - 1 To 1 Step -1
    
        If MSHFlexGrid1.TextMatrix(i, 1) .CellBackColor <> &H80FF& Then
        MSHFlexGrid1.RemoveItem i
        Else
            
        End If
    Next

Open in new window

LVL 11
Wilder1626Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
What happens when you run that code? Does it compile?
0
Martin LissOlder than dirtCommented:
Try this.

Dim i As Long
    MSHFlexGrid1.Col = 1
    For i = MSHFlexGrid1.Rows - 1 To 1 Step -1
    
        MSHFlexGrid1.Row = i
        If MSHFlexGrid1.CellBackColor <> &H80FF& Then
            MSHFlexGrid1.RemoveItem i
        Else
            
        End If
    Next

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Wilder1626Author Commented:
This is perfect.

Thanks again for your help.
0
Martin LissOlder than dirtCommented:
You're welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.