When the sprite moves to the left, you reduce the variable which controls it's X position. To stop it moving off the left side of the screen, immediately after the line which calculates it's screen X position you use something like:
If LeftKey()=1 Then Dec SpriteXPos: If SpriteXPos < 0 Then SpriteXPos = 0
Sprite 1,SpriteXPos,SpriteYPos,1
You repeat the same thing after the other three directions (not forgetting to take into account the sprite dimensions). Eg something like:
If LeftKey()=1 Then Dec SpriteXPos: If SpriteXPos < 0 Then SpriteXPos = 0
If RightKey()=1 Then Inc SpriteXPos: If SpriteXPos > Screen Width()-Sprite Width() Then SpriteXPos = Screen Width()-Sprite Width()
If UpKey()=1 Then Dec SpriteYPos: If SpriteYPos < 0 Then SpriteYPos = 0
If DownKey()=1 Then Inc SpriteYPos: If SpriteYPos > Screen Height()-Sprite Height() Then SpriteYPos = Screen Height()-Sprite Height()
Sprite 1,SpriteXPos,SpriteYPos,1
TDK_Man