Help to find Z and the Terrain...

Hey, my friends. Another quick help… my counter always get to 0 zero again after 9999… Could u guys solve that?

http://jungleclientes.com.br/clientes/3123321.png