CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2009
    Posts
    98

    [RESOLVED] Validate MSHFlexgrid1 cell with MSFlexgrid2 cell

    Hello all

    I have this code where i'm validating 2 MSHFlexgrid column to find if there is a same value:


    Code:
    Text1 = UCase(Trim(Form61.MSHFlexGrid1.TextMatrix(r1, 5)))
          Text2 = UCase(Trim(Form61.MSHFlexGrid2.TextMatrix(r2, 10)))

    But what i would like to do is to not validate the full cell value but only the 3 first digit.

    These digits are postal code. But i just need to see the 3 first digit.

    What do i need to do to do this base on the bellow code?

    On the code bellow, i've tried with:
    Code:
    Text1 = UCase(Left(Form61.MSHFlexGrid1.TextMatrix(r1, 3, 5)))
          Text2 = UCase(Left(Form61.MSHFlexGrid2.TextMatrix(r2, 3, 10)))
    But i have this compile error Wrong number of arguments or invalid property assignment.


    Thanks again for your help.

    Full code
    Code:
    Dim r1 As Long, r2 As Long, i As Long
    Dim Text1 As String
    Dim Text2 As String
    Dim bFound As Boolean
    
    'Part 1
    For r1 = 1 To Form61.MSHFlexGrid1.Rows - 1
       bFound = False
       For r2 = 1 To Form61.MSHFlexGrid2.Rows - 1
       Text1 = UCase(Left(Form61.MSHFlexGrid1.TextMatrix(r1, 3, 5)))
          Text2 = UCase(Left(Form61.MSHFlexGrid2.TextMatrix(r2, 3, 10)))
          If Text2 = Text1 Then
             bFound = False
             Exit For
          Else
             bFound = True
          End If
       Next r2
       
       
       If bFound And Form61.MSHFlexGrid1.TextMatrix(r1, 4) = "8" Then
          Form61.MSHFlexGrid1.TextMatrix(r1, 1) = "ZIP TO BE FIX"
          Form61.MSHFlexGrid1.Row = r1
          Form61.MSHFlexGrid1.Col = 1
          Form61.MSHFlexGrid1.CellBackColor = &H80FF&
    
          
       Else
         
          
       End If
    Next r1

  2. #2
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: Validate MSHFlexgrid1 cell with MSFlexgrid2 cell

    You have misplaced the brackets in this expression:
    Code:
    Text1 = UCase(Left(Form61.MSHFlexGrid1.TextMatrix(r1, 3, 5)))
    'this is (nearly) how it should be:
    Text1 = UCase(Left(Form61.MSHFlexGrid1.TextMatrix(r1, 3), 5))
    'and in addition you have twisted the arguments for the TextMatrix acces, so this is the right line:
    Text1 = UCase(Left(Form61.MSHFlexGrid1.TextMatrix(r1, 5), 3))
    'look:
    Text 1 = UCase(  Left( Form61.MSHFLexGrid1.TextMatrix(r1,5),  3 )   )

  3. #3
    Join Date
    Aug 2009
    Posts
    98

    Re: Validate MSHFlexgrid1 cell with MSFlexgrid2 cell

    This is perfect.

    Thanks again for your help. Now it work.

    Have a great day

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured