Current location - Education and Training Encyclopedia - University ranking - On the method of parameter transfer in VB program of Visual Basic in colleges and universities
On the method of parameter transfer in VB program of Visual Basic in colleges and universities
Passing a value only passes a copy of the variable. If the process changes this value, the change will only affect the copy, not the variable itself.

Address, pass parameters by address, and the procedure uses the memory address of the variable to access the contents of the actual variable. Therefore, when a variable is passed to a procedure, the value of the variable can be changed permanently through the procedure, and passing parameters by address is the default parameter passing method in vb.

Generally speaking, if the argument is a constant or an expression, and the corresponding parameter variable is preceded by the keyword By Val, then the value of the constant or expression is passed to the corresponding parameter in the called process, that is, the value is passed. If the argument is a variable or an array, and there is no keyword By Val before the argument variable, then the argument is passed to the formal parameter with the address, and then the argument and the formal parameter point to the same storage unit. Therefore, the change of parameters directly affects the independent variables in the called process.