I'm writing a routine to open a file using VB5's common dialog box. Only two types of files are allowed: txt and dat and I want the routine (btnOpen.click) to loop until a valid file is selected.<br><br>I've written something like the following for the click event:<br><br>Private Sub Command1_Click()<br><br>Dim LineIn as String, GoodFile As String, FileExt as String<br><br>GoodFile = "N"<br><br>Do Until GoodFile = "Y"<br> frmOpenFile.Show ' this is the cdl form<br> FileName = frmOpenFile!CommonDialog1.FileName<br> <br> FileExt = Ucase$(Right$(FileName, 3))<br><br> If FileExt = "EXE Or ... (other excluded types) Then<br> MsgBox "Invalid File Type"<br> frmOpenFile.Hide<br> FileName = ""<br> GoodFile = "N"<br> Else<br> GoodFile = "Y"<br> End If<br>Loop<br><br>Open FileName For Input As 1<br> ...<br><br>Close 1<br><br>End Sub<br><br>Routine seems to work the first time for a bad file (always works for a 'good' file) but the second time around for a bad one, it jumps out of the loop and tries to open something I don't want it to open OR, if I clear the file name in the common dialog box, it gives me a run-time error 'File or path not found'.<br><br>I KNOW it's right in front of me ... but I'm just not seeing what's wrong.<br><br>Any ideas/suggestions/fixes GRATEFULLY accepted.<br><br>Thanks!<br><br>Tom<br> <br>