A model is proposed to value a firm with stochastic earnings. It is assumed that the earnings of the firm follow a time-varying mean reverting stochastic process. It is shown that the value of the firm satisfies a boundary value problem of a second-order partial differential equation, which can be solved numerically. Some special cases are discussed. An analytic solution is found for one special case. Moreover, it is shown that the analytic solution is consistent with a previous result obtained by other researchers. Numerical solutions are obtained for the other special cases. Finally, the model is also applied to value the debt issued by the firm.