|
|
CODE ' Code courtesy of UtterAccess Wiki ' http://www.utteraccess.com/wiki/index.php/Category:FunctionLibrary ' ' 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 version ' 2.1 2010-09-10 reformat, remove previous commented version ' changed header ' no functional changes made since 2.0 '============================================================================== ' NAME: GetFilenameFromPath ' DESC: Removes directory from a complete filedesignation, returning filename ' Returns ZLS on input missing "/" or "\" ' this function requires Access 2000 or a custom InStrRev function. '============================================================================== Public Function GetFilenameFromPath(asPath) As String On Error GoTo Error_Proc Dim Ret As String '========================= Dim iPos As Integer '========================= iPos = InStrRev(asPath, "\") If iPos > 0 Then Ret = Mid$(asPath, iPos + 1) End If '========================= Exit_Proc: GetFilenameFromPath = Ret Exit Function Error_Proc: MsgBox "Error: " & Trim(Str(Err.Number)) & vbCrLf & _ "Desc: " & Err.Description & vbCrLf & vbCrLf & _ "Procedure: GetFilenameFromPath" _ , vbCritical, "Error!" Resume Exit_Proc Resume End Function
|
| This page was last modified 08:33, 6 April 2011. This page has been accessed 1,039 times. Disclaimers |