Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 486
  • Last Modified:

VB6 - Delete first Chars from MSFlexgrid if

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
Wilder1626
Asked:
Wilder1626
  • 5
  • 2
1 Solution
 
Martin LissOlder than dirtCommented:
MSHFlexGrid2.TextMatrix(grid_cust, 21) = Mid(MSHFlexGrid2.TextMatrix(grid_cust, 21),3)
0
 
Martin LissOlder than dirtCommented:
That would replace line 3.
0
 
Wilder1626Author Commented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
Martin LissOlder than dirtCommented:
textmatrix takes just two arguments

TextMatrix(rowindex, colindex)
0
 
Martin LissOlder than dirtCommented:
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
 
Wilder1626Author Commented:
Many thanks again

this is working great
0
 
Martin LissOlder than dirtCommented:
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
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now