Source code for Issue Number 16

Copyright 1997-2000 by C&D Programming Corp. All Rights Reserved. Source code may not be reproduced except for use in a compiled executable. All rights reserved. If you would like to reprint any or all of this code please email us at info@codeoftheweek.com

Code of the Week Home


Source Code

Just paste this code into any module (this is the desired way) or form. To do this, open up your project and insert a new Module. Change the name of the module to basStrings and paste this code into the module. If you have been following Code of the Week all along

'----------------------------------------------------------------------
'
'   Module Name:    basStrings
'   Written By:     C&D Programming Corp.
'   Create Date:    11/27/97
'   Copyright:      Copyright 1997 by C&D Programming Corp.  Source
'                   code may not be reproduced except for use in a
'                   compiled executable.  All rights reserved.  If
'                   you would like to reprint any or all of this
'                   code please email us at info@codeoftheweek.com
'
'   Purpose:        Add and remove backslashes from strings, most
'                   useful for pathnames.
'
'----------------------------------------------------------------------
Public Function AddBackslash(sStr As String) As String
    If Right(sStr, 1) <> "\" Then
        AddBackslash = sStr & "\"
    Else
        AddBackslash = sStr
    End If
End Function

Public Function RemoveBackslash(sStr As String) As String
    If Right(sStr, 1) = "\" Then
        RemoveBackslash = Left$(sStr, Len(sStr) - 1)
    Else
        RemoveBackslash = sStr
    End If
End Function