We present an algorithm to find the optimal point of a variational inequality problem. The domain of the function that defines the variational inequality is a convex set, determined by convex inequality constraints and affine equality constraints. The algorithm is based on a discrete variable structure closed-loop control system which presents sliding mode trajectories on the boundary of the feasible set until the optimal point is reached. The update law is designed using control Liapunov function (CLF), which guarantees the decrease of a discrete Liapunov function inside and outside the feasible set. The step size is optimized using Liapunov optimizing control (LOC).