In the Dir function (VBA) what is the function of the "ReadOnly" attribute? Seems vbNormal lists "ReadOnly" files too

Viewed 53

I was wondering what "ReadOnly" does. VbNormal returns all "ReadOnly" files too, so "vbNormal + vbReadOnly" combination seems to have no effect. But I guess it has to have some function.

Thank you very much for your idea.

Sub test()

x = Dir("C:\Folder\", vbNormal)   'It returns read-only files as well, but vbReadOnly is not given as condition

Do While x <> ""

        Debug.Print x
        x = Dir
        
Loop

End Sub
1 Answers

The Dir (and Dir$) functions are pretty ancient (they actually precede Microsoft) and I suspect that parts of them became obsolete long ago, but that the Help/Doc pages are autogenerated (VBA isn't really under active maintenance) so they keep spitting out irrelevant/misleading information.

O'Reilly seems to agree with this (here) saying the vbReadOnly flag (and some others) is a no-op. My suspicion is that the obsolete flags worked back in DOS days, but became disabled when everything was transferred to NT.

Related