The immersion of virtual reality (VR) has transcended the existing experience of multimedia teaching. This paper aims to design a virtual reality eye tracker device to analyze the cognitive process of program debugging by adopting virtual reality technology to build a 3D code rendering system and, at the same time, using eye tracking technology to study visual attention as well as to analyze and compare the differences in internal behavioral cognition in terms of program debugging. This paper has 32 students as participants who have studied C++ programming language courses for more than one year in the department of computer science. With Unity 3D development tool, the experiment creates a virtual classroom scene and C++ programming language code. The participants’ eye movements are recorded by an eye tracker device integrated in a Head-Mounted Display (HMD). The eye movement defines the regions of interest (ROIs) according to the division of the program’s function, and the difference in visual attention between various ROIs in the code is discussed when the participant performs the program debugging task. The finding results are expected to improve the dilemma of the existing programming teaching, so that the instructors can provide appropriate teaching aids for students to achieve the purpose of programming teaching and improving the students’ programming competence.