|Train in Southeast Alaska shot at f/5.6, 800 ISO, one-shot auto-focus in Av (A) mode.|
The image above was taken from a moving train of another train, which you see in the frame.
All you have to do to get sharp pictures while moving at almost any speed is to set your camera to shoot at an f/stop in Av mode (or A mode on a Nikon) of about 5.6 (not f/4, as you'll get a lousy depth of field).
To get good focus, set the auto-focus to one-shot, not rapid fire nor al servio. One-shot auto focus will be the fastest focus you can get.
Next for getting a sharp shot while moving is to set your ISO to 800. Sometimes you can get away with 400, especially if you have a camera that gives you noise above that. This setting will make the camera's shutter open and close faster because the sensitivity of the sensor will be high.
You should have your focus center-weighted also and aim at the subject you want the sharpest.