We apply the variational Monte Carlo method to study a particle in an infinite potential well. The probability density is sampled using the Metropolis algorithm. The aim of this work is to present in a pedagogical way both the method and its computer implementation.