|
|
 |
| Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book:
Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Visual Basic 2005 Basics section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

August 15th, 2008, 09:15 AM
|
|
Registered User
|
|
Join Date: Aug 2008
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Using Date in Visual Basic 2005.
How to get age in years(rounded off to nearest number) in a textbox3,suppose we are having Date of birth of a person in textbox2 and today's date in textbox1?
|

August 15th, 2008, 10:42 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 1 Time in 1 Post
|
|
Something like this:
Code:
Year(CDate("January 15, 2008")) - Year(CDate("September 9, 1985"))
almost gives you the answer. But it is only accurate after 9/9 any year. So if the date is after December 31, midnight (after New Year's), but before the birthday, you need to subtract 1.
Statements that are True or False = -1 if True, and 0 if False.
Adding a minus value subtracts the absolute value of it.
So if you [u]add</u> to the statement’s value (the purple part is pseudocode)
Code:
+ (TheDayOfTheYearOf(CDate(textbox1.Text)) < _
TheDayOfTheYearOf(CDate(textbox2.Text)) _
)
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |