Solved

VB6 - Delete first Chars from MSFlexgrid if

Posted on 2013-01-26
7
469 Views
Last Modified: 2013-01-26
Hello all

I'm trying to remove the 2 first characters form column 21 it the value in the cell start with RL.

Ex: If the value = RL123456, it will remove the RL and just leave 123456.

How can i do that?

Thanks again

        For grid_cust = 1 To MSHFlexGrid2.Rows - 1
        If Left(MSHFlexGrid2.TextMatrix(grid_cust, 21), 1, 2) = "RL" Then
            Left(MSHFlexGrid2.TextMatrix(grid_cust, 21), 1, 2) = ""
        End If
    Next grid_cust

Open in new window

0
Comment
Question by:Wilder1626
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 47

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 38823276
MSHFlexGrid2.TextMatrix(grid_cust, 21) = Mid(MSHFlexGrid2.TextMatrix(grid_cust, 21),3)
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 38823279
That would replace line 3.
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 38823288
Hi MartinLiss

It only work if i do this:
If Left(MSHFlexGrid2.TextMatrix(grid_cust, 21), 1) = "R" Then

But not this:
If Left(MSHFlexGrid2.TextMatrix(grid_cust, 21), 1, 2) = "RL" Then

It gives me an error: incorrect number of arguments

Do you know why?


    For grid_cust = 1 To MSHFlexGrid2.Rows - 1
        If Left(MSHFlexGrid2.TextMatrix(grid_cust, 21), 1) = "R" Then
            MSHFlexGrid2.TextMatrix(grid_cust, 21) = Mid(MSHFlexGrid2.TextMatrix(grid_cust, 21), 3)
        End If
    Next grid_cust

Open in new window

0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 47

Expert Comment

by:Martin Liss
ID: 38823294
textmatrix takes just two arguments

TextMatrix(rowindex, colindex)
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 38823300
So I think it should be the following assuming that grid_cust contains the row you want and 21 is the column

If Left(MSHFlexGrid2.TextMatrix(grid_cust, 21),2) = "RL" Then
0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 38823311
Many thanks again

this is working great
0
 
LVL 47

Expert Comment

by:Martin Liss
ID: 38823324
You're welcome and I'm glad I was able to help.

Select the 'About Me' tab in my profile and you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2012
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 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