private sub command1_click() on error goto aa sql1 = "select 姓名 from " & Text3.Text & " where 帐号='" & jiami(Text1.Text) & "'" ... ... exit sub aa: msgbox "错误:" & err.description,vbexclamation,"提示" exit sub end sub
sql1 = "select 姓名 from " & Text3.Text & " where 帐号='" & jiami(Text1.Text) & "'"
err:
错误发生应该执行的代码
on error goto aa
sql1 = "select 姓名 from " & Text3.Text & " where 帐号='" & jiami(Text1.Text) & "'"
...
...
exit sub
aa:
msgbox "错误:" & err.description,vbexclamation,"提示"
exit sub
end sub