A semiempirical functional of the Hartree-Fock type density, previously obtained for the Hartree-Fock atomic functions and applied with good success to the second row hydrides (in paper XXI of this series), is now applied to the molecules H2(X 1Σg+), Li2(X 1Σg+), Be2(1Σg+), B2(X 3Σg−), C2 (x1 Σg+), N2(X 1Σg+), O2(X 3Σg−), and F2(X 1Σg+). For each molecule the potential energy curve is computed from the repulsive region to large internuclear distances. In order to follow the dissociation to the correct limits, we have added to the Hartree-Fock configuration of each molecule those configurations which are needed for describing proper dissociation (HFPD functions). It is found that for certain molecules (Li2, B2, C2, and O2) there are configurations which contribute quite significantly in the bonding regions and must be added to the HFPD function to reach a proper reference state function as previously defined (see paper XXI). With our functional of the density applied to the HFPD functions, the calculated dissociation energies are, with the experimental values given in parentheses, 4.69 eV (4.75 eV), 0.65 eV (1.14 eV), 1.64 eV (3.0 eV), 3.48 eV (6.36 eV), 9.34 eV (9.91 eV), 3.75 eV (5.21 eV), and 1.37 eV (1.66 eV) for H2, Li2, B2, C2, N2, O2, and F2, respectively. More realistic dissociation energies are obtained for Li2 (1.03 eV), B2 (3.06 eV), C2 (5.21 eV), and O2 (4.64 eV) if we use the proper reference state functions. The Σg+1 state of Be2 arising from the ground state atoms is repulsive. The agreement with the experimental dissociation energy is satisfactory but not as good as what we have previously obtained for the second row hydrides. However, owing to the extreme simplicity of the method it appears in a preliminary way that the combination of a Hartree-Fock type function and the functional of its density (of the form that we have proposed) is capable of yielding sufficiently reliable results for very little computational and human effort. Since the parametrization of the density functional was made for the atomic systems and not changed in the molecular formation, our method does not suffer from the need of variation of parameters introduced ad hoc and differing from molecule to molecule.