blocker -3

Good day.!

How to get the last day of the current month and store it in a variable.?

Thank you for giving time.?

vb5prgrmr 143

Here are a couple of ways and by no means are these the only ways...

``````Option Explicit

Dim M As Integer, D As Integer, Y As Integer
Dim S As String, LastDay As Date

M = Month(Now)
D = Day(Now)
Y = Year(Now)

If IsDate(M & "/" & 28 & "/" & Y) = True Then D = 28
If IsDate(M & "/" & 29 & "/" & Y) = True Then D = 29
If IsDate(M & "/" & 30 & "/" & Y) = True Then D = 30
If IsDate(M & "/" & 41 & "/" & Y) = True Then D = 31

LastDay = M & "/" & D & "/" & Y
S = "The last day of this month is " & Format(LastDay, "dddd") & " "

MsgBox S & LastDay

'or
LastDay = M & "/" & 1 & "/" & Y

S = "The last day of this month is " & Format(LastDay, "dddd") & " "
MsgBox S & LastDay
End Sub``````

Good Luck

blocker -3

Here are a couple of ways and by no means are these the only ways...

``````Option Explicit

Dim M As Integer, D As Integer, Y As Integer
Dim S As String, LastDay As Date

M = Month(Now)
D = Day(Now)
Y = Year(Now)

If IsDate(M & "/" & 28 & "/" & Y) = True Then D = 28
If IsDate(M & "/" & 29 & "/" & Y) = True Then D = 29
If IsDate(M & "/" & 30 & "/" & Y) = True Then D = 30
If IsDate(M & "/" & 41 & "/" & Y) = True Then D = 31

LastDay = M & "/" & D & "/" & Y
S = "The last day of this month is " & Format(LastDay, "dddd") & " "

MsgBox S & LastDay

'or
LastDay = M & "/" & 1 & "/" & Y

S = "The last day of this month is " & Format(LastDay, "dddd") & " "
MsgBox S & LastDay
End Sub``````

Good Luck

Thank you for giving time with this problem. Anyway ive got i very simpler solution with this problem.the code below. This works very well.

``````Private Sub Form_Load()
Dim lastdayofmonth