This study evaluated students' affective learning in an introductory computing course that was taught in Hong Kong once in a lecture format and twice in a rich interactive multimedia online format to 414 college students in all. A simplified experience sampling method was used to assess affective learning at the midterm and end of each course in terms of intrinsic engagement (positive affect, perceived challenges, perceived skills in course activities), extrinsic engagement (performance expectations, performance goals, performance self-efficacy), and negative affect in course activities. Controlling for students' computing background and pre-enrolment academic ability, multivariate analysis of covariance indicated that, compared to lectures, e-learning modules fostered more intrinsic engagement, comparable extrinsic engagement, and more negative affect. Findings suggest directions for developing online courses that optimise both cognitive learning and affective learning. [Copyright of Educational Psychology is the property of Routledge. Full article may be available at the publisher's website: http://dx.doi.org/10.1080/01443410601061413]