Home All Groups Group Topic Archive Search About

No files selected in openfiledialog

Author
11 May 2010 1:46 PM
simonc
How can I test for openfiledialog OK clicked without any files being
selected? (I'm using it with multiple select as true.)

I've tried

if openfiledialog1.filenames = nothing then ...

and

if ubound(openfiledialog1.filenames) = -1 then ...

but both these give compile errors.

Grateful for advice.

Author
11 May 2010 1:58 PM
Herfried K. Wagner [MVP]
Am 11.05.2010 15:46, schrieb simonc:
> How can I test for openfiledialog OK clicked without any files being
> selected? (I'm using it with multiple select as true.)
>
> I've tried
>
> if openfiledialog1.filenames = nothing then ...
>
> and
>
> if ubound(openfiledialog1.filenames) = -1 then ...
>
> but both these give compile errors.

At least on Windows 7 I am not able to close the dialog by clicking the
"OK" button if no file is selected.

Maybe you are attempting to check if the "Cancel" button has been pressed?

\\\
If Me.OpenFileDialog1.ShowDialog() =
System.Windows.Forms.DialogResult.OK Then
     ...
Else
     ...
End If
///

--
  M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
  V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>