Article ID:qGEN007
Date Revised:November 24, 1997
Keywords:Calculator, Calendar, _CALCVALUE, _DIARYDATE
See Also:calccal.zip 

Question: How can I use the builtin Calculator and Calendar within my application?

Answer: The calculator and calendar store their result values in the system memvars _CALCVALUE and _DIARYDATE respectively.

The attached form launches the two items from a button Click() event with an ACTIVATE WINDOW command, it also enables a respective timer that polls once a second for the existence of the window.

* launch the calendar and enable the polling timer

activate window calendar
thisform.tmrCalendar.Enabled = .t.

For the calendar the timer takes the current value and fills a field with the currently selected date.

* grab the value every time the timer fires

thisform.txtDate.Value = _diarydate && update the value

* disable the timer when the window no longer exists

this.Enabled = wexist( "Calendar/Diary" )

For the calculator the timer only fills the field after the calculator has been closed.

* Don't get intermediate results, wait till calculator is closed

if ( ! wexist( "Calculator" ) )
   * if the window no longer exists update the value and disable
   thisform.txtCalculator.Value = _calcvalue
   this.Enabled = .f.
endif

The fields can also be used to manipulate the calendar and calculator. You can enter values in the field and then launch the objects and they will reflect the current values of the fields. There seems to be a bug in VFP5 build 412, that the calculator will not always recognize the decimal values when it is launched.


1