B
brzak
this is hopefully really simple
i came across a line in a short sub that i don't quite full
understand. The line in question is:
If Right$(fldr, 1) <> "\" Then fldr = fldr & "\"
why is it 'Right$' instead of simply 'Right' ?
I haven't seen any difference in behaviour for what i've been using it
on..
Is there an instance when it would be different?
Thanks
Brz
Code (http://www.ozgrid.com/forum/showthread.php?t=71409) is below:
Sub testit()
myvar = FileList("C:\")
For i = LBound(myvar) To UBound(myvar)
Debug.Print myvar(i)
Next
End Sub
Function FileList(fldr As String, Optional fltr As String = "*.*") As
Variant
Dim sTemp As String, sHldr As String
If Right$(fldr, 1) <> "\" Then fldr = fldr & "\"
sTemp = Dir(fldr & fltr)
If sTemp = "" Then
FileList = Split("No files found", "|") 'ensures an array is
returned
Exit Function
End If
Do
sHldr = Dir
If sHldr = "" Then Exit Do
sTemp = sTemp & "|" & sHldr
Loop
FileList = Split(sTemp, "|")
End Function
i came across a line in a short sub that i don't quite full
understand. The line in question is:
If Right$(fldr, 1) <> "\" Then fldr = fldr & "\"
why is it 'Right$' instead of simply 'Right' ?
I haven't seen any difference in behaviour for what i've been using it
on..
Is there an instance when it would be different?
Thanks
Brz
Code (http://www.ozgrid.com/forum/showthread.php?t=71409) is below:
Sub testit()
myvar = FileList("C:\")
For i = LBound(myvar) To UBound(myvar)
Debug.Print myvar(i)
Next
End Sub
Function FileList(fldr As String, Optional fltr As String = "*.*") As
Variant
Dim sTemp As String, sHldr As String
If Right$(fldr, 1) <> "\" Then fldr = fldr & "\"
sTemp = Dir(fldr & fltr)
If sTemp = "" Then
FileList = Split("No files found", "|") 'ensures an array is
returned
Exit Function
End If
Do
sHldr = Dir
If sHldr = "" Then Exit Do
sTemp = sTemp & "|" & sHldr
Loop
FileList = Split(sTemp, "|")
End Function