Board index » Visual Studio » Loop without Do
|
Theta
|
Loop without Do
Visual Studio81
Hi, I'm using the code below: It's almost an exact paste of sample code shown for "DIR" in the Help. I keep getting the Compile Error: 'Loop Without Do', but I DO have a DO. All I'm trying to do is determine whether a certain directory exists, not any files in the directory. In other words, I want to get a message back that the directory does/doesn't exist. I don't care right now what files might be in that directory, I just want to know if it exists. I suspect it's an obvious error, but I can't see it: ------------------- Option Explicit Option Compare Text ' Display the names in 'C:\Program Files' that represent directories. Private Sub Form_Click() Dim MyPath As String Dim MyName As String MyPath = "c:\program files\" ' Set the path. MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry. Do While MyName <>"" ' Start the loop. ' Ignore the current directory and the encompassing directory. If MyName <>"." And MyName <>".." Then ' Use bitwise comparison to make sure MyName is a directory. If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then End If MyName = Dir ' Get next entry. Loop End Sub --------------------- Dir, Loop, Do, Do while, etc., in Help, all seem to indicate I'm OK. What the heck as I doing wrong? TIA, Pop` - |
