Hello, I have this error, when I close a common dialog box in my app, it has a runtime error. Also happens when I click "cancel". This is because nothing is selected, anyone know how to fix this? Thanks.
Printable View
Hello, I have this error, when I close a common dialog box in my app, it has a runtime error. Also happens when I click "cancel". This is because nothing is selected, anyone know how to fix this? Thanks.
VB Code:
CommonDialog1.ShowOpen If CommonDialog1.FileName = "" Then MsgBox "You closed the dialog or you pressed cancel!" End If
But better is probably
VB Code:
On Error GoTo ErrorRoutine CommonDialog1.CancelError = True CommonDialog1.ShowOpen ErrorRoutine: If Err = 32755 Then MsgBox "You closed the dialog or you pressed cancel!" End If
To help you remember the error number more easily, use the constant -
cdlCancel (&H7FF3 Cancel was selected)
Good suggestion.Quote:
Originally Posted by RobDog888