1 Son düzenleyen, konuka (18.03.2014 14:21:39)

Konu: invalid date hatasını otomatik kaldırma yolu var mı

Örneğin

Visual Fox Pro
myForm.myTextbox.Value=DATE()

myForm.myTextbox.Tag=DTOC(DATE())

diye girelim.

Tarih değiştirirken geçersiz tarih yazıldığında "invalid date" mesajı verip boxu terk etmiyor.

Valid evente aşağıdakini yazdım:

Visual Fox Pro
IF  EMPTY(This.Value)  && hatalı tarih ise .t.

  This.Value=CTOD(This.Tag)
  RETURN 1  && sonraki kontrole geç
ENDIF

AMA buraya (Valid tetiklenmiyor) düşmüyor. Bu durumda "invalid date" mesajı ile ne tetikleniyor ?

VFP9 SP2

2 Son düzenleyen, ugurlu2001 (18.03.2014 15:24:17)

Re: invalid date hatasını otomatik kaldırma yolu var mı

Set Notify OFF ile sistem mesajını kapatabilirsin. Ama bu şekilde diğer tüm sistem hatalarına ait mesajlarıda gider.
Eğer tarih formatın hatalı ise try/catch bloğu içinde varsayılan bir değer ile ( yada empty) değiştirebilirsin.

İşlemin hemen akabinde Set Notify On yapmayı unutma.

Uğur
-------------------------------------------------------------------------------------------------------------
Hayat bir bisiklete binmek gibidir. Pedalı çevirmeye devam ettiğiniz sürece düşmezsiniz. Claude Peppeer
Kusuru söylenmeyen adam, ayıbını hüner sanır.  Türk Atasözü

3

Re: invalid date hatasını otomatik kaldırma yolu var mı

Benzer bir yazı :

http://fox.wikis.com/wc.dll?Wiki~UnTrappableErrors

You can't normally trap the case where the user enters an invalid date into a Text Box; VFP displays "Invalid Date" itself and doesn't fire the Valid method of the control. You can turn off the "Invalid Date" message with set notify off, but if you want the Valid method of the control to fire (for example, to give a different message or bring up a calendar), you'll have to set the StrictDateEntry property of the control to 0-Loose. One caveat: if the user enters an invalid date, it'll get blanked, so if you want to redisplay the former value, you'll have to save it in the GotFocus method of the control and restore it in the Valid.

Uğur
-------------------------------------------------------------------------------------------------------------
Hayat bir bisiklete binmek gibidir. Pedalı çevirmeye devam ettiğiniz sürece düşmezsiniz. Claude Peppeer
Kusuru söylenmeyen adam, ayıbını hüner sanır.  Türk Atasözü