I'm doing a basic homework assignment which 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 press 'cancel' on the input box. Then the string input is "", and I get the following error:
System.InvalidCastException {"Conversion from string "" to type 'Double' is not valid."}
I think I understand the error, I'm trying to convert using CDbl a non-numeric value. My question is what would be a more proper way to write this code? Is it the code, or just a lack of error handling?
Thanks
Aaron