The increasing interest in lunar exploration requires a better understanding of environment at the lunar surface. Like any object in plasma, the surface of the Moon charges to an electric potential that minimizes the total incident current. Surface charging is an universal process affecting all airless regolith-covered bodies. However, there are still many details that remain unclear and need to be discussed to understand those possible processes such as ion sputtering and electrically-driven dust transport. There are also many subjects that require further study, such as the temporal and spatial variation of lunar surface charging. Simulation and analysis of trajectories of the electrons under different conditions would help to predict surface potential, which in turn would benefit the understanding of the lunar environment. In this paper, the solar wind electrons which are moving toward the moon surface are traced to study the effect of surface potential on solar wind electrons reflected by the lunar crustal magnetic field. Statistic of number of electrons that reflected under different conditions is also analyzed. The calculations and simulations show that the variation of either magnetic field or potential difference does play an important role in the changing traces of electrons. Furthermore, the changes by the variations could be told from analysis of the results. Thus, the magnitude of crustal field and potential could be inferred from the data of instrument of LP (Lunar Prospector satellite). New devices could also be designed or developed in the coming lunar projects. Surface potentials are not always present on the Moon, so we could collect and analyze data under different conditions and thus obtain more precise results. However, there is one more important circumstance needed to be considered that the craft would be charged in the lunar environment. How to eliminate the influence of charged craft and get a more precise result are important problems for us to explore in the future.