CutString11

Cuts long string from certain character to certain character with option to jump CutFrom and ToString characters.
My most advanced CutString I came up with so far.
Will also work on searching for strings inside long string.
Will get the string starting 3rd space found and extract until 4th comma was found.

CodeFunctionName
What is this?

Public

Tested

Original Work
Function CutString11(FromString, Optional CutFrom = "", Optional CutFromOrder = 1, Optional ToString = "", Optional ToStringOrder = 1, Optional ByVal StartFromChar = 1)
    ' Will cut string from a larger string in more customized way
    ' Will start cutting when CutFrom was found after CutFromOrder number of times
    ' Then will keep reading until ToString was found for ToStringOrder number of times
    '
    ' example
    '    ? cutstring75("Common stock (par value $1.00 per share; 70.0 million shares authorized; 55.0 million, 53.2 million, and 52.5 million shares issued and
    '        outstanding at December 31, 2023, September 30, 2023, and December 31, 2022, respectively)", " ", 3,",", 4)
    '    value $1.00 per share; 70.0 million shares authorized; 55.0 million, 53.2 million, and 52.5 million shares issued and outstanding at December 31, 2023,
    ' Will get the string starting 3rd space and continue until 4th comma
    '
    ' Similar to CutString except it can be defined and controlled how many of these to start from and stop with
    '
    ' Needs VBInstr(), CutString1()
    Rett = ""
    If CutFrom = "" Then
        StartX1 = StartFromChar ' 1
    Else
        StartX1 = StartFromChar ' 1
        For i = 1 To CutFromOrder
            StartX1 = VBInstr(CutFrom, FromString, StartX1) + 1
        Next
    End If
   
    If ToString = "" Then
        EndX1 = Len(FromString)
    Else
        EndX1 = StartX1
        For i = 1 To ToStringOrder
            EndX1 = VBInstr(ToString, FromString, EndX1) + 1
        Next
        If EndX1 < > StartX1 Then
            EndX1 = EndX1 - Len(ToString)
        End If
    End If
    If EndX1 > StartX1 Then Rett = CutString1(FromString, StartX1, EndX1)
    CutString11 = Rett
End Function

FromString, Optional CutFrom = "", Optional CutFromOrder = 1, Optional ToString = "", Optional ToStringOrder = 1, Optional ByVal StartFromChar = 1

Views 178

Downloads 40

CodeID
DB ID