VB6 - Replace text in cell issue

Posted on 2013-10-07
Medium Priority
Last Modified: 2013-10-07
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", "")

Open in new window

Question by:Wilder1626
  • 2
  • 2
LVL 52

Expert Comment

by:Martin Liss
ID: 39554014
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.
LVL 11

Author Comment

ID: 39554018
Actually, it is column 7 but since it start at 0, i have put column 6
LVL 52

Accepted Solution

Martin Liss earned 2000 total points
ID: 39554032
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/
LVL 11

Author Closing Comment

ID: 39554058
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.

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

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.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

587 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question