窗体上有名称为Command1的命令按钮。事件过程及2个函数过程如下:

2024-11-02 09:22:24
推荐回答(1个)
回答1:

Private Sub Command1_Click() Dim x As Integer, y As Integer, z x = 3 y = 5 z = fy(y) '把y=5传给fy函数,返回的结果(也就是返回的y值)赋给z Print fx(fx(x)), y 'fx(fx(x))把x=3传给fx函数,返回的结果,再传给fx函数。最后结果输出是12 10 End Sub Function fx(ByVal a As Integer) a = a + a '第一回a=3+3=6,第二回a=6+6=12 fx = a 'fx=12 End Function Function fy(ByRef a As Integer) a = a + a 'a等于传来的5。a=a+a=5+5=10 fy = a 'fy=10 End Function