Can anyone explain why I get a result of zero?
When TheMonth variable is greater than 12, I want to set that variable to 1 (as in January); but when the code is ran the variable result is zero.
Why is it doing that?
Code:
Dim TheMonth As Integer
Dim Theyear As Long
Dim x As Integer
Lastdate = Mainarray(Erow, 1) <---Date
TheMonth = Month(Lastdate)
Theyear = Year(Lastdate)
For x = 1 To 6
TheMonth = TheMonth + 1
If TheMonth > 12 Then
[B]TheMonth = 1 And Theyear = Theyear + 1[/B]
End If
Why is it doing that?