This study investigates the effects of student use of self-regulated learning (SRL) strategies on their computer programming achievement. Ninety-six students from undergraduate teacher training programmes offered by a Hong Kong university voluntarily participated in the study. Sixty-six of them were first-year students enrolling on an introductory Java programming course, while 30 were second-year students enrolling on an advanced Java programming course. The SRL strategies adopted by participants were measured by the Motivated Strategies for Learning Questionnaire (MSLQ) and were exemplified from the reflective writing of their electronic portfolios. Their achievement in computer programming was evaluated using continuous and end of course assessments. The findings of this study suggest that higher-order cognitive strategies (i.e. elaboration, organization, critical thinking), metacognitive control strategies (i.e. self-regulation) and resource management strategies (i.e. time and study environment management, help seeking) are likely to facilitate a prolonged achievement of computer programming for both novices and non-novices. They can provide insights into designing adequate SRL strategy training to support student learning in computer programming.