I want to have an input box open up and ask the user to enter the number of items. I want to force this to be a positive integer. The following code (sort of) works:
While Not (no_of_items > 0)
no_of_items = InputBox("How many items?")
Wend
Two problems with this code
1) If the user enters a decimal it will accept it even though I want it to only accept integers.
2)If the user enters a string (ex: "two") then it will crash due to a type mismatch error since it is trying to evalute the no_of_items>0 statement with a string. If the user enters a string I would like to repeat the question until an integer is entered.
Any suggestion? Thanks in advance.
While Not (no_of_items > 0)
no_of_items = InputBox("How many items?")
Wend
Two problems with this code
1) If the user enters a decimal it will accept it even though I want it to only accept integers.
2)If the user enters a string (ex: "two") then it will crash due to a type mismatch error since it is trying to evalute the no_of_items>0 statement with a string. If the user enters a string I would like to repeat the question until an integer is entered.
Any suggestion? Thanks in advance.