VB code for exception handeling


Posted by Damien on June 23, 2001 9:24 PM

I have onjust noticed that when using an input box if the user hits the cancel button the macro with the input box code generates an error I know why but what exception handeling code do I use anyone?



Posted by Ivan F Moala on June 23, 2001 10:17 PM


Depending how you have Dim your resultant inputbox
msg to return then the result of a cancel = "" for
a String/variant or 0 for integer. eg

Dim Result as string

Result = Inputbox("enter fig")
If Result = "" then do something
Elses
Do some other thing
End If

In other words Always try and have options for
what you want the user to input AND for the user
to Cancel.
May pay to look @ Application.Inputbox method if
you want to restrict a users input.

HTH

Ivan