how to change just the year part of a vb.net date
How can i change just the year part of a date?
so if a user selects 3/10/2009 i want current to equal 3/10/2011
Dim current1 As Date
current1 = TextBox1.Text
current1.Year = Now.开发者_运维百科Year
date1 = DateTime.Parse(TextBox1.Text)
current1 = new Date(Now.Year, date1.Month, date1.Day)
You can probably do
current1 = current1.AddYears(2)
But you probably cannot do
current1 = TextBox1.Text
In order to parse a date from a string, you have to do this
current1 = DateTime.Parse(TextBox.Text)
精彩评论