We use intermolecular interactions to direct molecules into desired positions to create nanostructures, to connect functional molecules to the outside world, and to serve as test structures for measurements on single or bundled molecules. We use and develop scanning probe microscopes to determine both local structures and the electronic and other local properties. We have applied these to isolate molecules with electronic function to determine the mechanisms of function, and the relationships between molecular structure, environment, connection, coupling, and function. We have been able to demonstrate that single molecules can function as multistate switches, and have determined important aspects of the mechanism, function, and persistence of switching. We will discuss the origins of switching and the relevant aspects of the molecular structure and environment required.