Put your code into the LocationSensor.LocationChanged event handler. Speed is treated like a local variable, therefore you cannot use the speed variable in your showlocation Procedure.
Another way to do this would be to create a global variable ... perhaps mySpeed and in the LocationChanged event set mySpeed to speed and only THEN use mySpeed in place of speed in your showlocation Procedure.
Also be aware, that speed is only a valid number after the LocationSensor has made two separate LocationChanged events (a satellite fix has to be achieved twice .. the variable needs two different geocoordinate readings to calculate a speed.
For your else statement, rather than mySpeed > 8 you might use mySpeed > 8 and mySpeed <10 ... do you see why? Also, you want to be aware of the units output with speed
speed units - the LocationSensor reports speed in m/sec units), convert to km/hr if you want speed in kilometers (1000 meters) and also be aware m/sec must be addressed to convert kilometers/hour. m/sec * km/1000m * 60 sec/min * 60 min/hour = km/hour .
Your use of speed > 8 and <10 are suspect: 10 speed units (10 m/sec) is only about 22.4 miles per hour.
Regards,
Steve