VB6 - Remove apostrophe from MSHFlexgrid1 cells

Hi again.

I have a problem were i want to remove any apostrophe entered in cell 18 of each row, it would replace them by an empty space.

Ex:

"DRY VAN ' NEEDED" would be changed to "DRY VAN  NEEDED"

how can i do that?

Thanks again


Private Sub note_cell_18_Click()
Dim lngMSH_Row As Long
For lngMSH_Row = 1 To MSHFlexGrid1.Rows - 1
    If InStr(1, MSHFlexGrid1.TextMatrix(lngMSH_Row, 18), "'") > 0 Then
       InStr(1, MSHFlexGrid1.TextMatrix(lngMSH_Row, 18) = " "
    End If
Next
End Sub

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.

FaustulusCommented:
I know nothing about FlexGrid, but looking at the problem from the side of VB6 it seems to me like this code might work for you,
Private Sub note_cell_18_Click()
Dim lngMSH_Row As Long
For lngMSH_Row = 1 To MSHFlexGrid1.Rows - 1
    MSHFlexGrid1.TextMatrix(lngMSH_Row, 18) = Replace(MSHFlexGrid1.TextMatrix(lngMSH_Row, 18), "'", " ")
Next
End Sub

Open in new window

Note that an IF statement isn't required because it is implicit in the Replace function. What isn't found won't be replaced. If you wish to avoid having 2 consecutive spaces expand the code as follows.
Private Sub note_cell_18_Click()
Dim lngMSH_Row As Long
For lngMSH_Row = 1 To MSHFlexGrid1.Rows - 1
    MSHFlexGrid1.TextMatrix(lngMSH_Row, 18) = Replace(MSHFlexGrid1.TextMatrix(lngMSH_Row, 18), "'", " ")
    MSHFlexGrid1.TextMatrix(lngMSH_Row, 18) = Replace(MSHFlexGrid1.TextMatrix(lngMSH_Row, 18), "  ", " ")
Next
End Sub

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:
Thanks a lot for your help, this is working great.
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.