Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a textbox , i would entered a year like'1986' i want to calculated age year from given year please help me,
Posted
Comments
Ankur\m/ 7-Mar-14 2:13am    
At least give it a try, it isn't that hard.

Use the below

VB
Dim birthYear As Int32
If Int32.TryParse(txtAge.Text, birthYear) Then
    Dim age As Int32 = Date.Now.Year - birthYear
    MessageBox.Show("Your age is: " & age)
Else
    MessageBox.Show("Please enter a valid year of birth")
End If


Thanks,
-RG
 
Share this answer
 
 
Share this answer
 
v2
VB
DIM txtYear AS String = "1986"
Console.WriteLine(DateTime.Now.Year - txtYear)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900