# EqualRect Function

`Declare Function EqualRect Lib "user32.dll" (lpRect1 As RECT, lpRect2 As RECT) As Long`

EqualRect determines of two rectangles are equal. Rectangles are considered equal if and only if the upper-left and lower-right corners (the points that define the rectangles) of one rectangle are equal to those of another. In other words, two rectangles are equal if and only if they are exactly the same. The function returns 1 if the two rectangles are equal and 0 if they are unequal.

lpRect1
  The first of the two rectangles to check.
lpRect2
  The second of the two rectangles to check.

Example:

    Dim r As RECT, s As RECT
    ' Check to see if the rectangles are equal
    ' This example uses the SetRect API to define a rectangle
    x = SetRect(r, 50, 50, 150, 150)  ' (50, 50)-(150, 150)
    x = SetRect(s, 50, 50, 150, 150)  ' (50, 50)-(150, 150)
    Debug.Print EqualRect(r, s)  ' returns 1 -- they are equal
    x = SetRect(s, 100, 100, 200, 200)  ' (100, 100)-(200, 200)
    Debug.Print EqualRect(r, s)  ' returns 0 -- they are unequal

Related Call: CopyRect
Category: Rectangles
Back to the index.