Results 1 to 4 of 4

Thread: [RESOLVED] Using Replace function in a mshflexgrid

  1. #1

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Resolved [RESOLVED] Using Replace function in a mshflexgrid

    Keep getting an error trying to replace part of a string in a msflexgrid:
    The code that does not work:
    TextToReplace = "price adjusted for sales commission (.911)"
    For r = 1 To GridMisc.Rows - 1
    With Me.GridMisc
    If InStr(LCase(.TextMatrix(r, 2)), TextToReplace) Then
    .TextMatrix(r, 2) = .TextMatrix(r, 2) & Replace(TextToReplace, "")
    End If
    End With
    Next
    Typical string in grid:
    Software sold RoofCalculator 8.3 Michael C Douglass price adjusted for sales commission (.911)
    just trying to erase all after the name
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    Re: Using Replace function in a mshflexgrid

    Code:
    Dim r&, TextToReplace$, sTextMatrix$
    
    TextToReplace = " price adjusted for sales commission (.911)"
    
    With GridMisc
        For r = 1& To .Rows - 1&
            sTextMatrix = .TextMatrix(r, 2&)
    
            If InStr(1&, sTextMatrix, TextToReplace, vbTextCompare) Then
                .TextMatrix(r, 2&) = Replace(sTextMatrix, TextToReplace, vbNullString)
            End If
        Next
    End With
    Last edited by Bonnie West; Jan 30th, 2015 at 05:33 PM. Reason: Rearranged code snippet for efficiency
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3

    Thread Starter
    PowerPoster isnoend07's Avatar
    Join Date
    Feb 2007
    Posts
    3,237

    Re: Using Replace function in a mshflexgrid

    Thanks It's Fixed
    Waiting for a full featured smart phone with out marrying a provider
    Go Android
    Go raiders

  4. #4
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,143

    Re: Using Replace function in a mshflexgrid

    u wanna mark this as Resolved?

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