파일경로+파일명에서 파일명 또는 경로 알아내기 함수

파일경로+파일명에서 파일명 또는 경로 알아내기
Function GetFind(What As String, Optional division As String = “\”, Optional privious As Boolean) As String

Dim Length As Integer, i As Integer

If InStr(What, division) = 0 Then
GetFind = What
Exit Function
End If

Length = Len(division)

For i = Len(What) To Length Step -1
If Mid(What, i – Length, Length) = division Then
GetFind = IIf(privious, Left(What, i – Length – 2 + 1), Mid(What, i))
Exit Function
End If
Next

GetFind = What

End Function