On a generalization of the Miranda Theorem and its application to boundary value problems