is these function correct for test the collision?
Code:
Public Function TestCollision(X1 As Long, Y1 As Long, Width1 As Long, Height1 As Long, X2 As Long, Y2 As Long, Width2 As Long, Height2 As Long) As Boolean
    If (X1 + Width1 >= X2 And X1 <= X2 + Width2) And (Y1 + Height1 >= Y2 And Y1 <= Y2 + Height2) Then
        TestCollision = True
    Else
        TestCollision = False
    End If
End Function
i'm trying use it, but isn't working
Code:
Private Type CollisionDirections
    Left As Boolean
    Right As Boolean
    Up As Boolean
    Down As Boolean
End Type

Const PlayerSpeed As Integer = 5
Dim dirCollision As CollisionDirections

Private Sub sprPlayer_KeyDown(KeyCode As Integer, Shift As Integer, KeyDownTime As Long)
    Dim i As Integer
    
    If (KeyCode = vbKeyLeft) Then
        For i = 0 To sprWall.Count - 1
            If (sprPlayer.TestCollision(sprPlayer.Left - PlayerSpeed, sprPlayer.Top, sprPlayer.Width, sprPlayer.Height, sprWall(i).Left, sprWall(i).Top, sprWall(i).Width, sprWall(i).Height) = True) Then
                dirCollision.Left = True
            Else
                dirCollision.Left = False
            End If
            
            
        Next i
        
        If dirCollision.Left = False Then sprPlayer.Left = sprPlayer.Left - PlayerSpeed
.......
anyone can tell me what i'm doing wrong?