Web Development

General discussion


Visual Basic Common Dialog Cancel

By pokimaniac250 ·
I am working on a school project using Visual Basic 6 to make a copy of Windows XP Notepad. I'm working on the functionality of the Save/Save As menu items and am using the Visual Basic Common Dialog to set Save parameters. I use the CommonDialog.ShowSave to bring up the dialog, but whether I hit Save or Cancel during program execution, the next statement is executed saving the program. I need the dialog to return something saying that the user hit cancel, but I can't figure out which property it is. I would think it is the CommonDialog.CancelError, but that always returns False (or True if it was set to True previous to showing the dialog). Any Suggestions?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by lowlands In reply to Visual Basic Common Dialo ...

You are on the right track. You need to use Commondialog.CancelError. But you need to set it to true. That way an error is generated when the user clicks cancel. You'll now have to trap the error and have it cancel the save procedure.

Collapse -

by bckurd In reply to Visual Basic Common Dialo ...


it is not very complex at all. First, when you show up the dialog make sure that the dialog will pass a result to a variable what could keep the information if user has cancelled or saved etc. Here is an example what could give you some insight how to control dialog boxes... :)


Dim Result as DialogResult

Result = FileSaveDialog1.show
if Result = DialogResult.OK Then

' enter the statement you want to execute
'if user has already performed a positive action

end if

Collapse -

by pokimaniac250 In reply to Visual Basic Common Dialo ...

Thankyou both for your advice. I was able to get it to work by handling the error caused when the user hits the cancel button.

Related Discussions

Related Forums