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.
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.
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... :)
Cheers!
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
If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.
Visual Basic Common Dialog Cancel