→ MOONRAKER: 農友你好 你聽過DateTime嗎 03/14 13:38
→ renmax: 好的 我研究看看 謝謝 03/14 16:05
→ MOONRAKER: 你的問題應該是自己硬幹處理年月日的結果 03/14 16:52
→ MOONRAKER: 有DateTime那實在是太簡單了 03/14 16:53
→ MOONRAKER: .NET的DateTime是很先進的 你有寫php就知道了 03/14 16:54
使用DateTime後,我想知道選擇那一年的那個月有幾天
例如:選擇2012年2月的話,會顯示有29天
Public NowDate As DateTime = Now()
Dim day_control As String = NowDate.AddYears(DDL_Year_From.Text -
NowDate.Year).AddDays(1 - NowDate.Day).AddMonths(DDL_Month_From.Text -
NowDate.Month + 1).AddDays(-1).Day.ToString()
不知道有沒有更簡單的寫法呢?
謝謝
※ 編輯: renmax (61.216.21.87), 03/15/2016 09:55:07
推 ian90911: DateTime.DaysInMonth 03/15 10:31
→ renmax: 已解決 謝謝 03/15 18:22