VB6 - Replace text in cell issue

Hi ,

I have this code below were i woild like to see if i have the text "DC" in all MSHFlexgrid1 cell from column 6 and it there is, it willreplace "DC" by "".

But with the below code, it does not do any thing.

If i have the value: "DC06" in the cell, it stay"DC06" when it should be "06"

How can i fix this?

Thanks again for your help.


Dim lngMSH_Row11 As Long
For lngMSH_Row11 = 1 To MSHFlexGrid1.Rows - 1
    MSHFlexGrid1.TextMatrix(lngMSH_Row11, 6) = Replace(MSHFlexGrid1.TextMatrix(lngMSH_Row11, 6), "DC ", "")
    MSHFlexGrid1.TextMatrix(lngMSH_Row11, 6) = Replace(MSHFlexGrid1.TextMatrix(lngMSH_Row11, 6), "DC", "")
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:
When you say "column 6" is that a visual count from the left? If so then your code should reference column 5 rather than 6 since the columns start at 0.
0
Wilder1626Author Commented:
Actually, it is column 7 but since it start at 0, i have put column 6
0
Martin LissOlder than dirtCommented:
That's good.

Do you know how to use debug? I have an article here that may help if you aren't but in any case put a breakpoint on line 2 and then step through the code line by line using F8 and see what's in the the grid cells and what it does with the values/
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:
wow, i was using the wrong compilation to test the code. I was compiling 1 project and test the result with another shortcut icon from a backup of the previous update.

Sorry. :(

all work now.
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.