'in a module
Public Type MoveData
X As Long 'current X pos
Y As Long 'current Y pos
DeltaX As Integer 'number of units per change in X pos
DeltaY As Integer 'number of units per change in Y pos
XDir As Integer 'X direction, positive for right, negative for left
YDir As Integer 'Y direction, positive for down, negative for up because of the VB convention
End Type
'in the gen dec section of the form, or public in a module if you want
Dim Ball As MoveData
'wherever you have the movement, like a timer or something
'this assumes you have two pictureboxes, picGameBoard and picBall, and picBall has no border
With Ball
.X = .X + (.DeltaX * .XDir) 'do the X movement
.Y = .Y + (.DeltaY * .YDir) 'do the Y movement
'these statements change the direction of movement when the boundaries of
'the gameboard are reached
If .X >= (picGameBoard.ScaleWidth - picBall.Width) Then .XDir = -1
If .Y >= (picGameBoard.ScaleHeight - picBall.Height) Then .YDir = -1
If .X <= 0 Then .XDir = 1
If .Y <= 0 Then .YDir = 1
End With