A complex transcendental equation is derived, which is valid for a wide range of electron energies for semiconductor quantum heterostructures under unbiased or biased conditions. Its complex roots have as real parts the structure eigen-energy levels, and their imaginary parts are directly related to the lifetime of the corresponding eigen-energies. A numerical method is also presented capable of extracting all these complex eigen-energies. The method is based on the argument principle theorem from complex number theory. Therefore, all the energy levels and lifetimes of bound and quasibound states can be determined. Energy levels and lifetimes can also be calculated in the presence of scattering events when these are modeled with an energy broadening imaginary potential. Extensive comparisons between this numerical method and other currently used techniques are included, proving the generality and the accuracy of this new method.