Variational inequalities for functions on convex sets