StrictDateEntry

This text box property, added in Visual FoxPro 5.0, allows several shortcuts to date and datetime entry.

Usage

txtDateTime.StrictDataEntry = nOption
nOption = txtDateTime.StrictDateEntry

Parameter

Value

Meaning

nOption

0

Loose, allowing several shortcuts and new key characters.

1 (default)

Strict. Same as required form in older versions.


When StrictDateEntry is 0, loose data entry is allowed. That provides a couple of cool shortcuts. The year is assumed if not supplied. Starting an entry with the caret (^) forces date entry into YY-MM-DD format, regardless of SET DATE or the DateFormat property. Also, dates can be typed in delimited with all of the standard delimiters (the period, slash, hyphen) as well as whatever has been set globally with SET MARK or locally with DateMark. When StrictDateEntry is 1, you must enter the date in the format 99/99/99. The number of digits required for the century reflects the value of SET CENTURY (2 if OFF, 4 if ON). The order of the day, month and year is based on the current SET DATE setting.We've got mixed feelings about this feature. First, we never found it that hard to do date entry the old way. "If it was hard to write, it should be hard to use" is not our development philosophy, however, and especially in heads-down data-entry situations, it can be simpler to enter fewer characters. There is more burden upon the developer, too, because an incorrectly entered date will not generate an internal error, but rather force the text box's value to an empty datetime. Validation must be performed by the developer if required. In balancing the user convenience against the cost of development, testing and maintenance, we'll recommend this only for clients where it can offer a compelling advantage.

Example

oForm = createobject("form")
oForm.AddObject("txtDateEntry","TextBox")
WITH oForm.txtDateEntry
   .Visible = .t.
   .DateFormat = 14  && long
   .Width = 312
   .Value = DATETIME()
   .StrictDateEntry = 0
ENDWITH
oForm.Show()
* Key in a value, such as ^-2-14, and press Tab to observe the
* string properly translated.

See Also

DateFormat, DateMark, Set Date, Set Mark To, Set SysFormats


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .