Public Function F_GetPath(Optional argFullPath) As String ’指定されたフルパスから、最後の"\\"までの文字列を返す。 ’フルパスが省略された場合は、このMDBのパスを使用する。 ’最後の"\\"は付かない。 Dim strPATH As String Dim iCNT As Integer Dim iNEXT As Integer
F_GetPath = ""
If IsMissing(argFullPath) Then strPATH = CurrentDb().Name Else If argFullPath & "" = "" Then Exit Function End If strPATH = argFullPath End If
’最後の"\\"までループ
iNEXT = 0 iCNT = InStr(strPATH, "\\") Do Until iCNT = 0 iNEXT = iCNT + 1 iCNT = InStr(iNEXT, strPATH, "\\") Loop If iNEXT > 0 Then F_GetPath = Left(strPATH, iNEXT - 2) ’iNEXT - 1 にすると最後の"\\"含みになる
End If