Really? All you need is On Error Resume Next . Dead simple.
Really? All you need is On Error Resume Next . Dead simple.
I believe a more serious answer would be: You could easily trap the error number and make it pop up in a MsgBox, then decide what to do with each type of error. Complex objects or functions would often each need their own custom error handling code, but it wasn't hard to do.
What would a non-developer do after seeing an error number? Click OK and carry on? Might as well just resume next
The evidence shows that most writers of VB apps neither predicted errors nor found these error situations in testing.
The evidence shows that most writers of VB apps neither predicted errors nor found these error situations in testing.
So exactly like the current Javascript ecosystem then?
Private Sub cmdOk_Click()
On Error Resume Next
WInt = 0
HInt = 0
WInt = CInt(txtWidth.Text)
HInt = CInt(txtHeight.Text)
If CStr(WInt) <> txtWidth.Text Or CStr(HInt) <> txtHeight.Text Then
MsgBox "Invalid numeric values for the dimensions"
txtWidth.SetFocus
Exit Sub
End If
Tag = vbOK
Hide
End Sub
This basically asks for a width and height but the entry boxes are text so anything could be entered there. CInt tries to convert text to integer and if that fails it errors out. With 'On Error Resume Next' it moves on to the next if that fails instead of producing an error and WInt or HInt would remain whatever it was. Since they're initialized to 0 there are always some valid integers in there. CStr would convert the integer to string (0 if the string-to-integer failed) so that the assumption is that if the strings converted to integers and then converted back to strings weren't the same as the original strings there were some invalid characters in there.(in hindsight i should have also checked for negatives values but eh whatever)