Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

File Extension Function - VBA

RSS
Modified on Wed, Jun 18, 2014, 11:43 AM by Administrator Categorized as Microsoft Office, Visual Basic 6
Public Function LastIndexOf(searchIn As String, searchFor As String) As String

    LastIndexOf = InStrRev(searchIn, searchFor)

End Function

Public Function Suffix(searchIn As String, searchFor As String) As String

    Suffix = Right$(searchIn, Len(searchIn) - LastIndexOf(searchIn, searchFor))

End Function

Public Function FileExtension(fileSpec As String)

    Dim afterPeriod As String
    Dim afterSlash As String
    
    afterPeriod = Suffix(fileSpec, ".")
    afterSlash = Suffix(fileSpec, "\")
    
    If Len(afterPeriod) > Len(afterSlash) Then
        FileExtension = ""
    Else
        FileExtension = afterPeriod
    End If

End Function

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.