Help me with 2 basic problems.

Posts 1–5 of 5 · Page 1 of 1
Help me with 2 basic problems.
First problem.
Determining the if the year is a leap year or not. Whenever I try to put a year (leap year and non leap years), they all appear to be leap year. lol
We can say a year is a leap year when it is not a multiple of 100 and is divisible by four, and when a year is a multiple of 100 and is divisble by 400.
eg.
4 = leap year
6 = not leap year
1900 = not leap year
1600 = leap year

Second problem.
Determining the quadrant where the x and y variable lies. Example if x = 1 and y = 1, then a message box will appear telling its on Quadrant 1.
We can say a its on Q1 when x and y are >0, Q2 when x is >0 and y <0, Q3 when x and y are >0 and Q4 when x >0 and y <0.

Really need help. Can you please reply with the codes?

Thanks
Code:
If Date.IsLeapYear(Now.Year) Then
            MsgBox("true")
        Else
            MsgBox("false")
        End If
Alt:
Code:
Public Function blnLeapYear( _
intYear As Integer) As Boolean
blnLeapYear = False
If intYear Mod 4 = 0 Then
blnLeapYear = True
If intYear Mod 100 = 0 Then
If (intYear Mod 400) _
Then blnLeapYear = False
End If
End If
End Function

'action
if blnLeapYear(Now.year) = true
 msgbox("It is leap year")
else
msgbox("It's not leap year")
end if
_____________

Code:
If x >= 0 Then
            If y >= 0 Then
                msgbox("I -Quadrant")
            Else
                msgbox("IV-Quadrant")
            End If
    else
                If y >= 0 Then
                msgbox("II- Quadrant")
                Else
                msgbox("III-Quadrant")
            End If
        End If
@shugi99 Bored so here you go
I still can't get the first problem. Stupid me. And on the second one, whenever I put different variables on x and y, message box always say the point lies on Quadrant I. ><
Quote Originally Posted by shugi99 View Post
I still can't get the first problem. Stupid me. And on the second one, whenever I put different variables on x and y, message box always say the point lies on Quadrant I. ><
I've test both and they work
first one I gave you two optional ways of doing it

second one if y equals or is greater than 0 it will be a I-Quadrant
if y = -5 | x = 5 (example) it will be a IV-Quadrant

make sure your not just doing all positives
I tried using negatives. I just copied and pasted your codes and we tend to get different results. Is my visual basic in fault?
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Talk with us