Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Handling

Status
Not open for further replies.

kav123

Programmer
Jan 12, 2005
210
GB
I have written some error handling code in VB. However, even if there is no error, the program runs into the error handling label. I have set the error handling option, to break only on unhandled errors, in the visual studio.

Can anyone tell me how to sort this problem??
 
are you doing 'Exit Sub/Function' before your label?
 
write something like this:



on error goto errhandler

[your code]

[end code]


errhandler:

if err.number <> 0 then 'execute only if no error




select case err.number 'function relies on err.#

case is = 13
msgbox err.number & vbnewline & err.discription
err.clear 'make sure you reset err to 0
command1_click 'do something else, or try again


case is = 38757 'more examples
msgbox err.number & vbnewline & err.disctiption
err.clear
end

end select

end if
 
No i hadnt put Exit Sub/Function in the beginning, but since it was going into the error handling code, i have put it now.
 
Calypso06,this is what i have done now, though i do not have a separate error handling function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top