Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB4,VB5,VB6,VBS
Expertise: beginner
Jun 12, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

MakeFileName - Create a file name out of its parts

' Make a complete file name by assemblying its individual parts
' if Extension isn't omitted, it overwrites any extension held in BaseName

Function MakeFileName(Drive As String, Path As String, BaseName As String, _
    Optional Extension As String)

    ' add a trailing colon to the drive name, if needed
    MakeFileName = Drive & IIf(Right$(Drive, 1) <> ":", ":", "")
    ' add a trailing backslash to the path, if needed
    MakeFileName = MakeFileName & Path & IIf(Right$(Path, 1) <> "\", "\", "")
    If Len(Extension) = 0 Then
        ' no extension has been provided
        MakeFileName = MakeFileName & BaseName
    ElseIf InStr(BaseName, ".") = 0 Then
        ' the base name doesn't contain any extension
        MakeFileName = MakeFileName & BaseName & "." & Extension
        ' we need to drop the extension in the base name
        Dim i As Long
        For i = Len(BaseName) To 1 Step -1
            If Mid$(BaseName, i, 1) = "." Then
                MakeFileName = MakeFileName & Left$(BaseName, i) & Extension
                Exit For
            End If
    End If
End Function
Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date