kb24gunner10
New Member
- Joined
- Sep 29, 2014
- Messages
- 9
Hi,
I have an application which has a long list of prices. I have a sub that asks the user to enter a sample size out of the entire population of prices and then returns the average of a random sample of prices.
I want to use a double variable to take the price entered by the user instead of the variant type. So I have error checking turned on right before the input box stating "on error GoTo errorHandler:" and turned off right after the input box stating "on error GoTo 0" if the user enters a string into the input box rather than a number.
In the error handler, a message box displays a message saying you haven't entered a valid numeric value and then the next line says GoTo sample: (where "sample:" is the label right above the "on error GoTo errorhandler:" line is).
My problem is the error handler works fine if I enter text into the input box the first time but doesn't work the second time I enter text and it displays the usual run time error box the second time around. How would I get it to work to continuously not display the run time error box when text is entered?
I've gotten it to work using a variant data type for the variable that takes the input, but is there a way to get the error checker to work.
The code looks something like this
sample:
on error GoTo errorhandler:
sample = inputbox("enter sample size")
on error goto 0
lines of code
exit sub
errorhandler:
msgbox "enter numeric value"
GoTo sample:
end sub
Any help would be appreciated.
I have an application which has a long list of prices. I have a sub that asks the user to enter a sample size out of the entire population of prices and then returns the average of a random sample of prices.
I want to use a double variable to take the price entered by the user instead of the variant type. So I have error checking turned on right before the input box stating "on error GoTo errorHandler:" and turned off right after the input box stating "on error GoTo 0" if the user enters a string into the input box rather than a number.
In the error handler, a message box displays a message saying you haven't entered a valid numeric value and then the next line says GoTo sample: (where "sample:" is the label right above the "on error GoTo errorhandler:" line is).
My problem is the error handler works fine if I enter text into the input box the first time but doesn't work the second time I enter text and it displays the usual run time error box the second time around. How would I get it to work to continuously not display the run time error box when text is entered?
I've gotten it to work using a variant data type for the variable that takes the input, but is there a way to get the error checker to work.
The code looks something like this
sample:
on error GoTo errorhandler:
sample = inputbox("enter sample size")
on error goto 0
lines of code
exit sub
errorhandler:
msgbox "enter numeric value"
GoTo sample:
end sub
Any help would be appreciated.