VB6 - Replace value from cell if

Hi all

i would like to be able to replace a value of all cells in column 13 of my MSHFlexgrid 1 following this logic:

if in the cell i have the letter: D, then it should replace it with "DRY'.
 
if in the cell i have the letter: R, then it should replace it with "REEFER'.

How can i do that?

thanks again

Private Sub Command1_Click()
Dim lngMSH_Row As Long
For lngMSH_Row = 1 To MSHFlexgrid1.Rows - 1
    If MSHFlexGrid1.TextMatrix(lngMSH_Row, 13) like "%D%" Then
       MSHFlexGrid1.TextMatrix(lngMSH_Row, 13) = "DRY"
    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.

Martin LissOlder than dirtCommented:
Private Sub Command1_Click()
Dim lngMSH_Row As Long
For lngMSH_Row = 1 To MSHFlexgrid1.Rows - 1
    If Instr(1,IMSHFlexGrid1.TextMatrix(lngMSH_Row, 13) , "D") > 0 Then
       MSHFlexGrid1.TextMatrix(lngMSH_Row, 13) = "DRY"
    ElseIf  Instr(1,IMSHFlexGrid1.TextMatrix(lngMSH_Row, 13) , "R") > 0 Then
        MSHFlexGrid1.TextMatrix(lngMSH_Row, 13) = "REEFER"
    End If
Next
End Sub 

Open in new window


BTW do you mean "REFER", because "REEFER" is something totally different:)
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:
HI

Reefer for a temperature-controlled van.

Let me try this
0
Martin LissOlder than dirtCommented:
I never knew that it meant anything other than marijuana:)
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Wilder1626Author Commented:
ohhhhhh!!!!!, i did not now that.

I'm in Transport and we always use these terms below:

REEFER for temperature-controlled van
DRY for barn door van
HEAT for heated controlled van

Looks like it's working great for the code.

Just doing the last test.
0
Wilder1626Author Commented:
Thanks again and again for your help. this is working great.
0
Martin LissOlder than dirtCommented:
As always I'm glad I was able to help.

Marty - MVP 2009 to 2013
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.