-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
Delphi To/From
To/FromCODEGuides
Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

April Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyPascal and Delphi Coding BoardDelphi Object PASCAL Topic   Print This     

newbie needing help

newbie needing help in Delphi Object PASCAL topic (part of our Pascal and Delphi Coding group).

Quick Search: needing   newbie needing   newbie needing help  
Tokra
-- USA
right ive created a form with an edit box that i want them to fill in as a date of birth, and once the box is filled in the program automatically calculates the persons age, now ive placed a limit on the edit box but i want to know how do i get it to auto calculate the age once the limit is reached, because i dont want to place a button in that the user has to press to calculate the age of the person each time
 Posted 24 years ago (Thread Starter)
Comment Quote
About Tokra
Visit Profile
Membership pending.
Member subscribes to this thread but email is NOT VERIFIED.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #7035, 1 replies
Thread Started 7/18/2002 2:40:00 PM
View Counter=1151
Location=-- USA 
Joined=24 years ago   MB Posts=1  
Most Recent Post
Angel
 (Inactive)
England
The following code will calculate the users age for you.

procedure TForm1.Edit1Exit(Sender: TObject);
var
BirthDay : TDate;
Age : Variant;
S : String;
X : Integer;
begin
BirthDay := StrToDate(Edit1.Text); {Entered Birthday}
Age := Date - BirthDay; {Todays Date - Birthday = No of days Old}
S := Age / 365.25; {Divide days old by days in a year}
X := Pos('.',S); {Locate any decimal point in the result}
if X > 0 then Delete(S,X,100); {If decimal point exists delete the characters after it}
Label1.Caption := S; {Assign Age to label1}
end;

As for not wanting to have to press a button, I placed this code into the edit boxes onexit event so that when the user tabs out of the edit box their age is displayed. You could probably adapt this code witha Try Except statement and place it into the onChange event but I didnt try that.
 Posted 24 years ago
Comment Quote
About Angel
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #7041 (Level 1.1)  Reply to 7035
Thread Started 7/19/2002 2:36:00 AM
View Counter=2
Location=England  
Joined=25 years ago   MB Posts=199  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1213A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #7035 Counter
1151
Since 4/2/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2026 Prestwood IT Solutions.   [Security & Privacy]