If you know the random value, then reconstructing the original value is very simple.

You just have to keep in mind that working modulo p, you don't have actual numbers but remainder classes. The first p natural numbers are usually used as the representatives of these classes. Luckily, subtraction and addition are perfectly compatible with remainder classes.

The Mod implementation of VB converts any positive number to the representative of its remainder class. However, it can not do it on negative numbers. You have to do it on your own.