all groups > vb.net upgrade > november 2004 >
You're in the

vb.net upgrade

group:

FileOpenDialogue1 Cancel


FileOpenDialogue1 Cancel Tym
11/4/2004 12:42:11 PM
vb.net upgrade:
In VB6 I could used the CancelError property to trap for the cancel
button being pressed.

In vb.net I can't see this proprty any more.

I just use the

Try
FileOpen(iFileNum, OpenFileDialog1.FileName, OpenMode.Input)
Catch ex As Exception
MsgBox(ex.ToString)
Exit Sub
End Try

routine, where it gets caught with an exception and gives a long error
message.

Can I trap for the error button??

RE: FileOpenDialogue1 Cancel Nigel Armstrong
11/10/2004 5:49:08 AM
Hi Tym

You need to show the dialog using the ShowDialog() method. This returns a
DialogResult. The DialogResult has a variety of different values - the one
you want is DialogResult.Cancel. (DialogResult.OK is the positive action
when you click on the Open button)

Code like:

' Assumes we have a FileOpenDialog called FileOpenDialog1
If Me.FileOpenDialog1.ShowDialog = DialogResult.Cancel Then
MessageBox.Show("You pressed cancel...")
End If

HTH

Nigel

[quoted text, click to view]
AddThis Social Bookmark Button