指定文字列以前、以降削除

文字列から、指定した方向より削除文字列までを削除する。
削除文字列発見位置の指定あり
# 引数情報指定
~~~
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' 指定文字列以前、以降削除
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' 引数情報初期化
'------------------------------------------------------------------------------
Public Property Get G_String_InitArgDelInf() As T_STRING_ARG_DEL_INF
    Dim wkInf As T_STRING_ARG_DEL_INF
    
    With G_String_InitArgDelInf
        .SrchInf = G_String_InitArgSrchInf
        
        .DelPosSpec = E_STRING_SPEC_POS_START
        .AddDelFlg = False
    End With
    
    G_String_InitArgDelInf = wkInf
End Property

'------------------------------------------------------------------------------
' 指定文字列以降、以前削除（引数情報指定）
'------------------------------------------------------------------------------
Public Function F_String_ReturnDeleteStr_Inf( _
        ByRef aArgInf As T_STRING_ARG_DEL_INF) As String
    Dim wkRtn As String
    
    Dim wkArgInf As T_STRING_ARG_DEL_INF: wkArgInf = aArgInf
    Dim wkInfAryAry As Variant, wkInfAry As Variant
    Dim wkDelStt As Long, wkDelEnd As Long
    Dim wkStrLen As Long
    
    '文字列位置取得
    With wkArgInf
        wkRtn = .SrchInf.Target
        
        '検索文字列作成
        If F_String_GetSearchInfArray_Inf(wkInfAryAry, .SrchInf) <> True Then
            '検索文字が見つからなかった場合は無視
        Else
            wkStrLen = Len(.SrchInf.Target)
            
            '開始～文字列位置まで削除
            If M_Common.F_CheckBitOn(.DelPosSpec, E_STRING_SPEC_POS_START) = True Then
                '削除開始位置を設定
                wkDelStt = .SrchInf.SttPos
                
                '削除終了位置を設定
                wkDelEnd = wkInfAryAry(LBound(wkInfAryAry))(E_STRING_IDX_SRCH_INF_POS_START)
                '削除文字列追加指定ありの場合
                If .AddDelFlg = True Then
                    wkDelEnd = wkDelEnd - 1
                '削除文字列追加指定なしの場合
                Else
                    wkDelEnd = wkDelEnd + wkInfAryAry(LBound(wkInfAryAry))(E_STRING_IDX_SRCH_INF_LENGTH) - 1
                End If
            '文字列位置～終了まで削除
            Else
                '削除開始位置を設定
                wkDelStt = wkInfAryAry(LBound(wkInfAryAry))(E_STRING_IDX_SRCH_INF_POS_START)
                '削除文字列追加指定ありの場合
                If .AddDelFlg = True And wkDelStt > D_POS_START Then
                    wkDelStt = wkDelStt + wkInfAryAry(LBound(wkInfAryAry))(E_STRING_IDX_SRCH_INF_LENGTH)
                End If
                
                '削除終了位置を設定
                wkDelEnd = .SrchInf.EndPos
                If wkDelEnd < D_POS_START Then
                    PF_String_GetPosEndAdjust wkDelEnd, wkStrLen, .SrchInf.SttPos, .SrchInf.Length
                End If
            End If
            
            '削除位置に問題ない場合、削除実施
            If wkDelStt <= wkDelEnd Then
                wkRtn = ""
                If wkDelStt > 1 Then
                    wkRtn = Left(.SrchInf.Target, wkDelStt - 1)
                End If
                If wkDelEnd < wkStrLen Then
                    wkRtn = wkRtn & Right(.SrchInf.Target, (wkStrLen - wkDelEnd))
                End If
            End If
        End If
    End With
    
    F_String_ReturnDeleteStr_Inf = wkRtn
End Function
~~~
# 引数指定
~~~
'------------------------------------------------------------------------------
' 指定文字列以降、以前削除（引数指定）
'------------------------------------------------------------------------------
Public Function F_String_ReturnDeleteStr( _
        ByVal aTarget As String, _
        ByVal aDelete As String, _
        Optional ByVal aDelPosSpec As E_STRING_SPEC = E_STRING_SPEC_POS_START, _
        Optional ByVal aDelIdx As Long = D_IDX_START) As String
    Dim wkArgInf As T_STRING_ARG_DEL_INF: wkArgInf = G_String_InitArgDelInf
    
    With wkArgInf
        .SrchInf.Target = aTarget
        .SrchInf.Search = aDelete
        .SrchInf.GetIdx = aDelIdx
        
        .DelPosSpec = aDelPosSpec
    End With
    
    F_String_ReturnDeleteStr = F_String_ReturnDeleteStr_Inf(wkArgInf)
End Function
~~~