开发者

how to change just the year part of a vb.net date

开发者 https://www.devze.com 2023-02-17 11:22 出处:网络
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

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消