We present an approach to the implementation of the virtual crystal approximation (VCA) for the study of properties of solid solutions in the context of density-functional methods. Our approach can easily be applied to any type of pseudopotential, and also has the advantage that it can be used to obtain estimates of the atomic forces that would arise if the real atoms were present, thus giving insight into the expected displacements in the real alloy. We have applied this VCA technique within the Vanderbilt ultrasoft-pseudopotential scheme to predict dielectric and piezoelectric properties of the Pb(Zr[0.5],Ti[0.5])O[3] solid solution in its paraelectric and ferroelectric phases, respectively. Comparison with calculations performed on ordered alloy supercells and with data on parents compounds demonstrates the adequacy of using the VCA for perovskite solid solutions. In particular, the VCA approach reproduces the anomalous Born effective charges and the large value of the piezoelectric coefficients.