|
|
CODE ' Code courtesy of UtterAccess Wiki ' http://www.utteraccess.com/wiki/index.php/Category:FunctionLibrary ' 2010, August 10th ' ' You are free to use this code in any application, ' provided this notice is left unchanged. ' ' REV DATE DESCRIPTION ' 1.0 2010-08-10 initial release ' 2.0 2010-09-03 made faster, commented previous code ' 2.1 2010-09-12 changed header ' removed commented previous version ' no functional change singe 2.0 '============================================================================== ' NAME: GetFilePath ' DESC: Returns the path portion of a full file name, or ZLS on bad input ' (finds the last "\" in the string and returns up to that character) ' this function requires Access 2000 or a custom InStrRev function. '============================================================================== Public Function GetFilePath( _ aPath As String, _ Optional bIncludeTrailingSlash As Boolean = False) As String On Error GoTo Error_Proc Dim Ret As String '========================= Dim iPos As Integer '========================= iPos = InStrRev(aPath, "\") If iPos > 0 Then Ret = Left$(aPath, iPos + Not bIncludeTrailingSlash) End If '========================= Exit_Proc: GetFilePath = Ret Exit Function Error_Proc: MsgBox "Error: " & Trim(Str(Err.Number)) & vbCrLf & _ "Desc: " & Err.Description & vbCrLf & vbCrLf & _ "Procedure: GetFilePath" _ , vbCritical, "Error!" Resume Exit_Proc Resume End Function
|
| This page was last modified 08:31, 6 April 2011. This page has been accessed 1,385 times. Disclaimers |