[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 483
  • 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 LissRetired ProgrammerCommented:
MSHFlexGrid2.TextMatrix(grid_cust, 21) = Mid(MSHFlexGrid2.TextMatrix(grid_cust, 21),3)
0
 
Martin LissRetired ProgrammerCommented:
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
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!

 
Martin LissRetired ProgrammerCommented:
textmatrix takes just two arguments

TextMatrix(rowindex, colindex)
0
 
Martin LissRetired ProgrammerCommented:
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 LissRetired ProgrammerCommented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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