473,322 Members | 1,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Generate age from a datetimepicker

Can someone Plz help me build my application ?
I mean how can I Auto Generating Age in a textbox using datetimepicker in VB code plz.
Feb 19 '08 #1
3 5842
QVeen72
1,445 Expert 1GB
Hi,

You mean to say, you use DateTime Picker for Date of Birth,
and after selecting want to show age in textbox..?

REgards
Veena
Feb 19 '08 #2
jamesd0142
469 256MB
Hi,

You mean to say, you use DateTime Picker for Date of Birth,
and after selecting want to show age in textbox..?

REgards
Veena
find todays date and the date selected in dateTime picker then use

datdiff() function to work out age.
Feb 19 '08 #3
mafaisal
142 100+
Hello

Try this

Expand|Select|Wrap|Line Numbers
  1. Private Function GetAge(DOB As Date) As Integer
  2. Dim Age As Integer
  3. If DOB > Date Then GetAge = 0: Exit Function
  4. Age = Year(Date) - Year(DOB)
  5. If Month(DOB) > Month(Date) Or (Month(DOB) = Month(Date) And Day(DOB) > Day(Date)) Then
  6.  Age = Age - 1
  7. End If
  8. GetAge = Age
  9. End Function
  10.  
  11.  
Using Thsese Function U Can Get Age
Here DOB is Date
Use DTPicker is To set DateofBirth

Faisal

Can someone Plz help me build my application ?
I mean how can I Auto Generating Age in a textbox using datetimepicker in VB code plz.
Feb 19 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Angelina | last post by:
Hi, I have got two DateTimePicker's on my form to accept a guest arrival date and departure date.what i want to acheieve is ensure that the DateTimePicker2 (departure) is always greater than...
9
by: Guy | last post by:
I have extended the datetimepicker control to incorporate a ReadOnly property. I have used the new keyword to implement my own version of the value property, so that if readonly == true then it...
1
by: John Smith | last post by:
Hey folks, Got some strange behavior going on here. I have a datetimepicker with showcheckbox = true; If I set Checked=true and set the Text of the datetimepicker, then then the Checked...
0
by: Sumit | last post by:
Hi all, I have a datetimepicker on my windows form. When the user selects it i check whether the date entered is a Sunday or not & if its not a sunday i want that the control remains on the...
4
by: Jacek Jurkowski | last post by:
.... the minimum date of DateTimePicker is 1753-01-01. How to make DateTime to do not show nothing in its text if this date is the value? I have a form with a field LastLogonDate. If user hasn't...
7
by: Clamara | last post by:
When adding a new record from my form, I pre-set my DateTimePicker's value to System.DateTime.Today Since the "Today" value is used most of the time, the user doesn't need to select a date from...
3
by: Charlie | last post by:
In the top portion of the DateTimePicker, where the value of the date is displayed, how can I detect whether the month or day or year is currently focused, or, if ShowCheckBox = True, whether the...
3
by: Simon Tamman | last post by:
I've come across an interesting bug. I have workarounds but i'd like to know the root of the problem. I've stripped it down into a short file and hope someone might have an idea about what's going...
4
by: jehugaleahsa | last post by:
Hello: We were hoping to allow users to have DateTimePicker value null so that a unused date is stored on a Database. Does the control support this? I am pretty sure it doesn't. How would you...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.