Invalid listing during input
I'm doing basic homework that looks like this:
While input <> -1
input = CDbl(InputBox("Enter numbers to add, enter -1 to stop"))
values = values + input
End While
It works fine until I click "cancel" on the input field. Then I input the string "" and I get the following error:
System.InvalidCastException {"Conversion from string ""
to type 'Double' is not valid."}
I think I understand the error, I am trying to convert using CDbl to a non-numeric value. My question is, what would be the more correct way to write this code? Is this code or just a lack of error handling?
0
source to share