为什么小弟我运行的时候调用fun1(x,y)时,x=m+n:y=m-n;到这一步的时候第一个m=8而第2个m确等于10

为什么我运行的时候调用fun1(x,y)时,x=m+n:y=m-n;到这一步的时候第一个m=8而第2个m确等于10?
Dim x As Integer, y As Integer
Private Sub Command1_Click()
Dim a As Integer, b As Integer
a = 5: b = 3
Call sub1(a, b)
Print a, b
Print x, y

End Sub
Private Sub sub1(ByVal m As Integer, n As Integer)
Dim y As Integer
x = m + n: y = m - n

m = fun1(x, y)
n = fun1(y, x)
End Sub
Private Function fun1(a As Integer, b As Integer) As Integer

x = a + b:y = a - b
Print a, b
Print x, y
fun1 = x + y
End Function


------解决方案--------------------
Dim x As Integer, y As Integer ***此处的x,y是全局变量,VB默认的是按地址传递,不是按值传递。
Private Sub Command1_Click() ***程序从这里开始
Dim a As Integer, b As Integer 
a = 5: b = 3
Call sub1(a, b) ****调用sub1()过程,即call sub1(5,3) 转GotoA
Print a, b 
Print x, y 
End Sub 
************************以上是Command1_Click**********************

************************以下是sub1()过程*************************
GotoA:
Private Sub sub1(ByVal m As Integer, n As Integer) ***m=5,n=3
Dim y As Integer ****此过程的y为局部变量,x则是全局变量。
x = m + n: y = m - n ****x=5+3,y=5-3
m = fun1(x, y) *****调用函数fun1(),即m=fun1(8,2),转GotoB
n = fun1(y, x) 
End Sub 
************************以上是sub1()过程*************************

************************以下是fun1()过程*************************
GotoB:
Private Function fun1(a As Integer, b As Integer) As Integer ***a=8,b=2 此处,x,y均为全局变量。
Print a, b ****第一次输入 8,2
x = a + b ****x=8+2,此后x=10,因是按地址传递,a和x指向的是同一个地址,所以,a也变成了10
y = a - b *****y=10-2
Print a, b 第二次输入 10,2
Print x, y 
fun1 = x + y 
End Function 
************************以下是fun1()过程*************************
以上就是解释,希望楼主能看明白。