Msgbox Retry/cancel buttons are confusing me
Solved/Closed
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
-
May 27, 2011 at 10:47 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Jun 3, 2011 at 07:50 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Jun 3, 2011 at 07:50 AM
Related:
- Retry.me
- Asus volume buttons not working - Guide
- How to cancel classmates.com - Guide
- Free app to cancel subscriptions - Guide
- How to cancel tinder gold - Guide
- How to cancel tiktok subscription - Guide
1 response
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
May 27, 2011 at 10:57 AM
May 27, 2011 at 10:57 AM
Hi Trowa
I think you are not assigning the value from msgbox to any variable
I think you are not assigning the value from msgbox to any variable
I = MsgBox("De opgegeven datum komt niet overeen met het type (mmm jjjj), als in ""Jan 2011"".", vbRetryCancel, "Foutmelding") If (i = vbRetry) Then GoTo cm ElseIf I = vbCancel Then Exit Sub End If
May 30, 2011 at 09:14 AM
Thanks for your reply.
This solves 1 out of 3 questions.
The Cancel button on the Msgbox will now exit the sub. Question solved.
Remaining questions:
1. The Retry button on the Msgbox will only work 1 time (or the error handling will only work 1 time). The second time a wrong entry has been made a VB error occurs instead of displaying the defined error message with the option to retry. Users will be pretty confused when suddenly the VB window pops up. What can I do to prevent this?
2. By default the Cancel button on the Inputbox will result in the value "". Is there a way to exit the sub when Cancel is chosen?
It's probably a good idea to upload my file, but I understood that you cannot acces speedyshare. Google docs doesn't seem to be suited for codes. See if you can acces this site:
http://www.mediafire.com/?pe76y6e5ocu7flr
Your assistance is much appreciated.
Best regards,
Trowa
May 30, 2011 at 09:17 AM
May 30, 2011 at 09:42 AM
May 30, 2011 at 09:55 AM
May 30, 2011 at 05:08 PM
After inputbox there is a check to see what value is being passed. If it is "". then control is directed to exit of sub. The reason I have a "goto", instead of direct "exit sub" was due to fact that you were freezing the screen update before error could occur. So when exit sub occurs, we should reset the it back to true ( I think). Of course a simple IF block could have done the trick, but I tend to believe that all exit from function and sub should be done at one spot (or as much as possible as I find it easier to run debug)
Also I think only thing that you need to check is retry. As if user selects retry you want to send the user back to select a valid value. For any thing else, I am guessing user wants to get out. So that is the reason in ErrorMessage, I am only testing for retry and if it is a retry that send the control back. If you notice I have used a Resume Cm instead of Goto CM. In case of a loop, first time error handler will work but later on it will give you an error. By clearing the error and saying resume from that label we avoid that situation.
Last is one more call to on error goto 0. This is to remove the On Error goto ErrorMessage handle. This resets error handler back to VBA default. So when error occurs, you get the error message as if you never had an error handler
Sorry for not being clear in explanation above, but hope it at least helps is some what.
thanks