Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Year 0000
Message
 
 
To
14/04/2005 13:15:31
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01003937
Message ID:
01004859
Views:
26
I make it to work, thanks again: Do you see any problems here?
*---------------------- Location Section ------------------------
*   Library: 	Acustomcontrols.vcx
*   Class: 		Txtdate
*   Method: 	Rangelow()
*----------------------- Usage Section --------------------------
*)  Description:
*)

*   Scope:      Public
*   Parameters:
*$  Usage:
*$
*   Returns:
*--------------------- Maintenance Section ----------------------
*   Change Log:
*       CREATED 	04/14/2005 - NN - idea by Fabio Lunardon thread #1003937
*		MODIFIED
*----------------------------------------------------------------
LOCAL llError
llError = .f.
do case

case type('this.value') = "D" AND EMPTY(this.Value)
	if !empty(chrtran(this.text,"/.-",""))
		*This.Value=CTOD("^"+STR(YEAR(DATE()),4)+"-"+STR(MONTH(DATE()),2)+"-"+LEFT(This.Text,2))
		=ErrorMsg('Please enter a valid date',0+16,"Error in date entry")
		llError = .t.
	endif

case type('this.value') = "T" AND EMPTY(this.Value)
	local lcText
	lcText = strtran(this.text,"AM","")
	lcText = strtran(m.lcText,"PM","")
	lcText = strtran(m.lcText,"M","")

	if !empty(chrtran(m.lcText,"/.:-",""))
*This.Value=CTOD("^"+STR(YEAR(DATE()),4)+"-"+STR(MONTH(DATE()),2)+"-"+LEFT(This.Text,2))
		=ErrorMsg('Please enter a valid date',0+16,"Error in date entry")
        llError = .t.
	endif

case this.value < this.dRangeLowBound
	=ErrorMsg('Please enter a correct year',0+16,"Error in date entry")
	llError = .t.
endcase

return IIF(m.llError, this.dRangeLowBound, {}) && so it would work for empty dates
>>>>My question is how to trap years less than 1900 in valid of the textbox. It seems like this year is converted to 1900 by VFP... Try to play with form and textbox which is date type.
>>>
>>>Can you explain better ?
>>
>>Create a test form. Put textbox on a form and set its value to =date(10,15,1965). Now run the form and try to change year to 0000. The "Invalid date" message would appear only when you put 1/1/0000 or any date less than 03/01/0000 (I'm using SET DATE TO American). But when you click on this textbox again you'll see, that the year automatically was converted to 1900 if you put something like 3/2/0000.
>>
>>In my date class I want to trap all years less than currrent year - 110 and display a message. Yesterday I tried to implement it, but it didn't work. However, I spent ~ 5 minutes on it because it was at the end of the day. If you have ideas how to achieve my goal, they are more than welcommed, otherwise I'll start playing with it myself.
>
>
>* RangeLow
>RETURN GOMONTH(DATE(),-110*12) && this is the lowerBound
>
>
>
>** Class RangeLow
>IF m.this.Value<m.this.RangeLowBound && ADD THIS PROPERTY
>   MESSAGEBOX("Error ... blb bls ...")
>ENDIF
>RETURN m.this.RangeLowBound
>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform