Board index » delphi » SpinEdit - Error Trapping

SpinEdit - Error Trapping

If my user erases the entry in a SpinEdit, leaving it blank, and tabs out of
the SpinEdit, a EConvertError is raised.  How do I trap that?  I've tried to
do something in the SpinEdit's OnExit event, but so far, no success.

 

Re:SpinEdit - Error Trapping


Quote
David Howorth wrote:

> If my user erases the entry in a SpinEdit, leaving it blank, and tabs out of
> the SpinEdit, a EConvertError is raised.  How do I trap that?  I've tried to
> do something in the SpinEdit's OnExit event, but so far, no success.

You will have to change the source that gets the text and converts it to
a value, chack for an empty string and make the value zero.

Bye

--

-----------------------------------
Arjan Lamaker
IMAG-DLO Wageningen The Netherlands
mail: e.j.j.lama...@imag.dlo.nl
http://huizen.dds.nl/~lamaker/
------------------------------

-----

Re:SpinEdit - Error Trapping


Quote
Arjan Lamaker <e.j.j.lama...@imag.dlo.nl> wrote:
>David Howorth wrote:

>> If my user erases the entry in a SpinEdit, leaving it blank, and tabs out of
>> the SpinEdit, a EConvertError is raised.  How do I trap that?  I've tried to
>> do something in the SpinEdit's OnExit event, but so far, no success.
>You will have to change the source that gets the text and converts it to
>a value, chack for an empty string and make the value zero.

Of course you could always prevent your user from blanking out the
field in the first place.
Thomas Paul
TOMG...@Pipeline.Com
Dean Witter, Discover & Co.
----------------------------------
All opinions expressed are my own.  My employer would
never be quite that stupid.
----------------------------------

Re:SpinEdit - Error Trapping


Quote
David Howorth wrote:

> If my user erases the entry in a SpinEdit, leaving it blank, and tabs out of
> the SpinEdit, a EConvertError is raised.  How do I trap that?  I've tried to
> do something in the SpinEdit's OnExit event, but so far, no success.

Interesting.

I tried this on my own program.  I didn't get the error, but it read the
value as the MinValue.  To make it display it, I put the following code
in the OnExit event:

  ( Sender as TSpinEdit ).value := ( Sender as TSpinEdit ).value;

I then pointed all of my SpinEdit OnExits to this and all works fine.

Bit of a hack really...

Ian

--
----------------------------------------------------------------
Dr Ian Johnson
IMJ Consultants

ph/fax:  Within Australia:       067 712133
         Outside Australia: (+61) 67 712133
email:   green...@northnet.com.au
----------------------------------------------------------------

Other Threads