Partial Path Formatting

By | 2019-09-29

Ensures the path contains a trailing backslash.

Module

Public Sub CheckPath(MyPath$) ' Adds the \ to the Application Path when required
    MyPath$ = App.Path
    If Not Right(MyPath$, 1) = "\" Then
        MyPath$ = MyPath$ & "\"
    End If
End Sub

Usage

Private Sub Command1_Click()
    Dim MyPath As String
    Dim FileName As String

    FileName = App.EXEName
    Call CheckPath(MyPath$)
    MsgBox "The location of: " & FileName & " is " & MyPath$ & vbCrLf & " Full Path: " & MyPath$ & FileName
End Sub

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.