VBA 常用自定义截取函数smid

Public Function smid(ostr, lstr As String, rstr As String)
    'Debug.Print ostr
    'Debug.Print lstr
    'Debug.Print rstr
    

    If InStr(ostr, lstr) <= 0 Or InStr(ostr, rstr) <= 0 Then
        smid = ""
    Else
        iStart = InStr(ostr, lstr) + Len(lstr)
        iEnd = InStr(iStart, ostr, rstr)
        Debug.Print "iStart:" & iStart
        Debug.Print "iEnd:" & iEnd
        smid = Mid(ostr, iStart, iEnd - iStart)
    End If
      '  Debug.Print smid
End Function

你可能感兴趣的:(VBA 常用自定义截取函数smid)