(06-17-2022, 03:12 AM)bplus Wrote: Uhmmm, unless temp$ is shared (which would be kinda odd) your sub doesn't do anything to the state of the program outside the sub???
It certainly doesn't change Path$, you would need a final line Path$ = Temp$.
Dang you did DIM Shared Temp$, sorry I suck at reading!
IMHO this is how I would handle this function:
Code: (Select All)
' don't share temp$, temp$ is supposed to be temporary!!!
test$ = "C:\Dir1\Dir2\"
Print CleanPath$(test$)
Function CleanPath$ (Path$) ' this is clearly a Function in my opinion!
' Remove quotes and trailing backslash from a path
' To use this subroutine: Pass the path to this sub, the sub will return the path
' without quotes and a trailing backslash in Temp$.
Dim x As Integer
' start by stripping the quotes
Temp$ = ""
For x = 1 To Len(Path$)
If Mid$(Path$, x, 1) <> Chr$(34) Then
Temp$ = Temp$ + Mid$(Path$, x, 1)
End If
Next x
' Remove the trailing backslash, if present
If Right$(Temp$, 1) = "\" Then
Temp$ = Left$(Temp$, (Len(Temp$) - 1))
End If
CleanPath$ = Temp$
End Function
How do you get double quotes in a path or filename? (Just really curious!)
b = b + ...