I'm modifying a VB5 app to allow it to ask the user to save a file or to cancel.
After calling CommonDialog1.ShowOpen, I'd like to know if the user clicked on the cancel button.
I've seen answers that sets the CommonDialog1.CancelError=True, calls the ShowOpen method, then checks for Err.Number (see below for example -- excerpt from another response):
Private Sub Command1_Click()
On Error Resume Next
CommonDialog1.CancelError = True
'CommonDialog1.FileName = ""
If Err.Number > 0 Then
MsgBox "Cancel is Clicked"
MsgBox "OK is Clicked"
My question is: Do I have to declare the Err as an Integer somewhere else in the code prior to the CommonDialog1.ShowOpen code, or it's automatically declared and populated by the ShowOpen? I have a scenario similar to above and I keep on getting Err.Number = 0 even if I clicked on the 'Cancel' button.
Also, what does "On Error Resume Next" mean?
Thanks and looking forward to anyone's help.