A simple method is described for calculating electronic states in narrow semiconducting wires near threshold, where there are few electrons in the system and the potential in which the electrons move can be found purely from electrostatics. The pinning of the chemical potential on the surface of GaAs and (Al,Ga)As means that the surface can be treated as an equipotential, a great simplification that permits analytic solutions. The method is applied to wires fabricated by several techniques, either in epitaxial or modulation-doped layers. The width of the wavefunction can be reduced to about 20 nm in a typical shallow-etched wire or one 'squeezed' under a split gate. Energy levels for motion parallel to the interface are about 10 meV apart while those for motion normal to the interface are separated by about 40 meV. These relative scales are similar to those calculated by Laux and Stern (1986, 1988) for narrow channels in silicon. Confinement can be improved by putting the electrons closer to the surface. Comparison with the numerical work of Laux, Frank and Stern (1988) on squeezed wires in GaAs shows some differences which are traced to the appearance of an inversion layer of holes when there is a large negative bias on the gate. It is possible to define a depletion width for a two-dimensional electron gas with this method, as half the width of a deep etched mesa at the point where electrons just appear. Agreement with the experiments of Choi, Tsui and Alavi (1987) is acceptable, but highlights the problem of defining a unique depletion width in a two-dimensional system.