Search Tools Links Login

Partial Path Formatting

Posted: 2019-09-30
By: DavidCostelloe
Viewed: 167

Filed Under:

VB6 String Handling, VB6 Code Cache

No attachments for this post


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

Special Instructions

This code originally appeared on AndreaVB.com, and has been republished here with the permission of Andrea Tincani.


Comments on this post

No comments have been added for this post.

You must be logged in to make a comment.