View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Error Handling Problem

Without seeing the code and knowing where the error generates, it is
difficult to be sure, but could you not cast the text into a date, and if
the date is invalid it will error at that point which you can trap,
something like

On Error Resume Next
myDate = CDate(Textbox1.Text)
If myDate = 0 Then
MsgBox "Error"
End If

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Minitman" wrote in message
...
Greetings,

How do I set up an error handling routine that does not though me into
an endless loop?

I have a UserForm (UF1) with a TextBox (TB1), in which I need a date
entered into. When I exit TB1, I have the format changed to mmm dd,
yyyy. This works fine. the problem arises when the person entering
the data mistypes something in TB1 and it is NOT a legitimate date.
On exiting TB1, they get an error message telling them that they have
a type mismatch asking about debug. I have tried to use on error to
generate a msgbox and then unload the userform and then reload it, but
that just freezes my machine and I have to Control, Alt, Delete out of
Excel (we wont discuss lost data at this time).

So, the question is how do I set up an error handling routine? Is
there any info out there on the logic and design of error handling
routines? Any help would be appreciated.

TIA

-Minitman