How to get previous month and year
Code
Dim dtr As String
text1.Text = "01/2011" 'User Input.... (mm/yyyy)
dtr = text1.Text
If user selected 01/2011 then date should display previous month and year...
Expected Output
Can anyone help me to do this?
Building on the answer I provided on your last question...
Dim dt As Date
Dim DaysInLastMonth As Integer
Dim LastMonth As String
dt = CDate(txtPeriod.Text)
dt = DateAdd("m", -1, dt)
LastMonth = Format$(dt, "mm/yyyy")
DaysInLastMonth = DateDiff("d", dt, DateAdd("m", 1, dt))
MsgBox LastMonth & vbCrLf & DaysInLastMonth