Use byval and byref
Byval only transmits parameters.
If byref defines a parameter pointing to it, it will pass the value back.
Not very clear!
In Visual Basic, you can specify keywords by specifyingByvalOrByref, Pass the parameter to the process by value or by reference. Passing parameters through values means that the process cannot be calledCodeModify the content of the basic variable element of the parameter. You can use the same method to modify the content of the variable element by referencing the transfer procedure.
The difference between passing parameters by value and by reference is different from dividing the data type into value type and reference type. However, the two categories do affect each other.
If you use keywordsByrefBy referencing and passing variable parameters, the process can modify the variable itself. Specifically, if the parameter is an object variable, you can assign it a new object. This type of reallocation will also affect the callProgramObject variable.
In the example provided by passing the byval parameter, if the replace subroutine is changed to get the parameter array by referencing, the new array K () will be allocated to the array Variable N in the call code. The result of N () is as follows:
Msgbox ("after Replace (n) taking a () argument byref:" & _ CSTR (N (0) & CSTR (N (1 )) & CSTR (N (2) & CSTR (N (3) 'The element values of N () are now 101,201, and 301. because N was 'passed byref, replace cocould modify the Variable N and assign a new' array to it. because N is a reference type, replace cocould also change its members