You are always going to run the error code unless you get out.
Try...
Private Sub cmdAdd_Click()
On Error GoTo errmsg
// main code: calculation work perform here.
On Error GoTo 0
Exit sub ' Get out of here!!!!
errmsg:
MsgBox "Adding can't execute due to the textbox is empty.", vbOKOnly )
End Sub
In this particular case though... Why not just test to see if there is any
text in the text box?
Error handling comes up quite frequently on these lists and a lot of it is
down to personal preference. *My* preference FWIW is to deal with each error
seperately and "in line".
Option Explicit
Public igErrNum as integer
----------------
Sub subSomeSub
On Error Resume Next
// Single Line of code that could error
igErrNum = Err.Number
On error goto 0
Select case igErrNum
Case 0
Case ....
Case ....
Case else
End select
Repeat for each line that could error.
End Sub
If anyone wants to jump in here with their own preferences please do feel
free to do so!