![]() ![]() MsgBox ("Please make sure a number is inputted") Sub TestError1()Īnd at the end of the procedure before End Sub, we need to put an Exit Sub, and then put the label errorhandler, and a message box with the error message. We therefore need to create an error handler at the top of the procedure using On Error Goto. We need to trap this error to make sure that the user does not type text into this particular text box – but only types a number. ![]() In the above example, due to the fact that the variable is an integer variable, it will not accept a text string – we therefore have a type mismatch. When you run the routine, an input box will ask you to enter a value.īecause text was entered, and not a value, an error will be returned.Ĭlicking on debug will show you the error, and resting your mouse on the line of code will give you the values or any variables or constants that occur in that line of code. IntA = InputBox("Please enter a value", "Testing errors") If you were to populate an integer with a text string as in the procedure below… Sub TestError Handling an error when incorrect data is inputted by the user Handling an error when incorrect data comes from a spreadsheet.Handling an error when incorrect data is inputted by the user. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |