Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What's The FoxPro Equivalent To VB's IsDate() Function 3

Status
Not open for further replies.

drosenkranz

Programmer
Sep 13, 2000
360
US
What's the FoxPro function to ascertain if the user entered a valid date into a text box?
The 2nd mouse gets the cheese.
 
Hello.

Under VFP you don't need that. Is sufficient to store in the .Value property a calendaristic date. The textbox will take care of rest.

You can do this storing directly a date (i.e. =DATE()), but in this case the textbox will have the today date all the time, or storing a blank date, writing in the .Value property ={}. In this case, the text box will have a date format, but will be blank.

Hope this helps. Grigore Dolghin
Class Software
Bucharest, Romania
 
To validate if a value is a date you can use the
VARTYPE(MyVar) == 'D' check (or VARTYPE(MyVar) == 'T' in case of a dataetime).

To be certain that your user enters a date in a textbox, you should use the InputMask and Format properties, see MSDN textbox properties.

HTH,

Weedz (Wietze Veld)
veld4663@exact.nl

They cling emotionally to code and fix development rather than choosing practices based on analytical assesments of what works best.

After the GoldRush - Steve McConnell
 
Hi my friend,

You can use...
Code:
? TYPE('Your_Date_Variable_Here')='D'

[code]
This will return true if your variable hold a value of valid date.
Hope this will help Walid Magd
Engwam@Hotmail.com
 
Walid,
Actually some might suggest that while:

Your_Date_Variable_Here = { // }
? TYPE('Your_Date_Variable_Here')='D'

shows a valid date varible, it is NOT a valid date.

Rick




 
That's where the EMPTY function comes into play.

Your_Date_Variable_Here = { // }
? TYPE('Your_Date_Variable_Here')='D AND !EMPTY(Your_DateVariable_Here) Jon Hawkins

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top