Dim d As Date = Now.Date
Dim p As Date
p = d.AddMonths(-1)
Dim a As Integer = p.DaysInMonth(Year(p), Month(p))
Dim m1 As New Date(Year(p), Month(p), 1)
Dim m2 As New Date(Year(p), Month(p), a)
MessageBox.Show(m1.ToString)
MessageBox.Show(m2.ToString)
呵呵,错了一个变量,代码拿来要仔细看看,表一味COPY,否则知识永远是人家的
兰冰的做法比较通俗吧,闵峰Dim d As Date = Now.Date
Dim p As Date
p = d.AddMonths(-1)
Dim a As Integer = p.DaysInMonth(Year(p), Month(p))
Dim m1 As New Date(Year(p), Month(p), 1)
Dim m2 As New Date(Year(p), Month(p), a)
MessageBox.Show(m1.ToString)
MessageBox.Show(m1.ToString)
的方法论只能输出上月第一天,无法输出上月最后一天
Dim d As Date = Now.Date
Dim p As Date
p = d.AddMonths(-1)
Dim a As Integer = p.DaysInMonth(Year(p), Month(p))
Dim m1 As New Date(Year(p), Month(p), 1)
Dim m2 As New Date(Year(p), Month(p), a)
MessageBox.Show(m1.ToString)
MessageBox.Show(m1.ToString)