Iamlaosong
Baidu, it is easy to find the Debug. Print explanation and usage introduction. In fact, it is very simple, that isThe code execution result is displayed in the "immediate window" without affecting program execution. VBADuring program debugging, you often need to monitor the value of a variable. Although msgbox can also complete this function, using Debug. Print to display the value of a variable or expression has many advantages, such:
1. The execution of the program is not affected. Although msgbox can also display the code execution result, you must press the OK button each time to continue. A large loop statement cannot be executed;
2. After the program debugging is completed, these debugging statements should be blocked. However, even the legacy Debug. Print does not affect the user's use, msgbox does not;
3. The biggest advantage is that the value of a variable can be studied slowly in the "immediate window" and copied out for research. For example, we want to synthesize an SQL statement, but the execution fails, where is the error? The variables and values in the program are mixed together, so it is difficult to find out the error points, especially when there are many quotation marks and parentheses. Copy the merged SQL statement and execute it to easily find the problem, msgbox does not work.
VBA debugging tool Debug. Print