Is this program correct?

Paul, please give more information . . .

Paul,  we can help you here but we do need a bit more information to go on.

Firstly, which PicAxe chip are you using, and are you using one of the pre-built PicAxe boards or is this on a board of your own design?  Also, how is the robot steering?  From the code it looks like you’re controlling direction both with motors and a servo - Is this right?   A good photograph of the robot and a circuit diagram would help us enormously.

The first thing that stands out in the code is that you’re using pin 0 both as an analogue input for the range sensor and an output for the servo.  Pin 0 can do both, but not in the same circuit. Which pins are these actually connected to?

Post back with the answers and we’ll see what we can do for you.