choknut Posted May 19, 2006 Posted May 19, 2006 (edited) i had a datetimepicker named dtpBirthDate, and want to use this as a meduim for obtaining birthdate of a user, what i want to happen exactly is upon choosing the date, three(3) textboxes namely, tboxYears, tboxMonths,tboxDays would be fill up by the number of years,months,and days the user was. here's the code: Dim tStart As DateTime = Me.dtpBirthDate.Value Dim tFinish As DateTime = Now() Dim TotalTime As TimeSpan = tFinish.Subtract(tStart) Dim dd As Double = TotalTime.TotalDays Me.tboxYears.Text = ((TotalTime.TotalDays) / 365.25).ToString Me.tboxMonths.Text = (((TotalTime.TotalDays) / 365.25) * 12).ToString Me.tboxDays.Text = TotalTime.TotalDays.ToString problem is it shows how many years,months and days it takes from the selected day to now, which is not the way i really wanted to show...and also it shows in decimal numbers not whole number.thanks again... Edited May 21, 2006 by PlausiblyDamp Quote
Administrators PlausiblyDamp Posted May 21, 2006 Administrators Posted May 21, 2006 Not quite sure exactly what you are trying to display - if you mean to show something like 16 years, 4 months and 17 days then the timespan object has the properties .Years, .Months and .Days - this will prevent you needing to do the calculations yourself. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
choknut Posted May 22, 2006 Author Posted May 22, 2006 thanks for your reply palusibledump, but i'm afraid if timespan has really properties .Years and .Months.Only .Days I suppose... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.