Yes just as the above posts has stated the On Error Resume Next statement just goes on to the next line if an error is raised. But this could make some unexpected results.
Consider this code:
This would of course popup a message that stated that the result is two if the user has typed in 5 in the Text1 textbox, right.Code:Public Sub AnExample() Dim sngDivider As Single On Error Resume Next sngDivider = Val(Text1.Text) If 10 / sngDivider = 2 Then MsgBox "The Result Is 2" Else MsgBox "The Result Is Not 2" End If End Sub
Well consider that the user has typed in 0 (zero) or a non numeric text. Then the if statement would raise an error, you can't divide by zero.
But since we got an On Error Resume Next statement it would just go on with the next line and popup the MsgBox that stated that the result is 2.




Reply With Quote