borderAndreaVB free resources for Visual Basic developersborder

AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincani
:: Returns the filename from a path

Author  

David Costelloe

Language  

VB5, VB6

Operating Systems  

Windows 95, 98 and NT
Module

Function GetFileName(fname As String) As String
    Dim i As Long

    On Error Resume Next
    For i = Len(fname) To 1 Step -1
        If Mid(fname, i, 1) = "\" Then
            Exit For
        End If
    Next i
    GetFileName = Trim(Mid(fname, i + 1))
End Function

Usage

'Usage:
Private Sub Command1_Click()
   
' Good for removing the path
    MsgBox GetFileName("C:\Windows\System\moricons.dll")
End Sub

:: Navigation

Home

Files and Disks Tips

Previous Tip

Next Tip

:: Search this site
Google
:: Related Topics
icon 04-10-2005 Re: HELP!!!! by TJ_01
icon 23-07-2005 ADO SQL problem by Jan_VB6
icon 13-04-2004 Getting Hardware Info by Shady
icon 23-02-2004 retrieve a file creation date by yronium
icon 28-01-2004 Re: Avi file by Goran
Partners: Il portale per lui e lei | Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder