VFP Age Calculator

*!* VFP Age Calculator

*!* Author : Lyrad Bangoy

Public loAgeCalc

loAgeCalc=Newobject(“form1”)
loAgeCalc.Show
Return

Define Class form1 As Form

BorderStyle = 1
Height = 134
Width = 251
DoCreate = .T.
AutoCenter = .T.
Caption = “Age Calculator”
MaxButton = .F.
MinButton = .F.
Name = “Form1”

Add Object txtdcurrentdate As TextBox With ;
Enabled = .F., ;
Height = 23, ;
Left = 122, ;
Top = 19, ;
Width = 100, ;
Name = “txtdCurrentDate”

Add Object txtdbirthdate As TextBox With ;
Alignment = 3, ;
Value = {}, ;
Height = 23, ;
Left = 122, ;
Top = 55, ;
Width = 100, ;
Name = “txtdBirthDate”

Add Object txtnage As TextBox With ;
Alignment = 3, ;
Value = 0.00, ;
Enabled = .F., ;
Height = 23, ;
Left = 122, ;
Top = 91, ;
Width = 100, ;
Name = “txtnAge”

Add Object label1 As Label With ;
AutoSize = .T., ;
Caption = “Today is:”, ;
Height = 17, ;
Left = 63, ;
Top = 22, ;
Width = 51, ;
Name = “Label1”

Add Object label2 As Label With ;
AutoSize = .T., ;
Caption = “Your Birth date:”, ;
Height = 17, ;
Left = 29, ;
Top = 58, ;
Width = 85, ;
Name = “Label2”

Add Object label3 As Label With ;
AutoSize = .T., ;
Caption = “Your Age is:”, ;
Height = 17, ;
Left = 47, ;
Top = 94, ;
Width = 67, ;
Name = “Label3”

Procedure txtdcurrentdate.Init
This.Value = Date()
Endproc

Procedure txtdbirthdate.Valid
Thisform.txtnage.Value = (Thisform.txtdcurrentdate.Value-This.Value)/365
Endproc

Enddefine

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s