Private Sub f(g() As Integer, x() As Integer)
g(1) = 11 - x(1) - x(2)
g(2) = 6 - x(1)
g(3) = 8 - x(2)
g(4) = x(1)
g(5) = x(2)
End Sub
在调用函数f时,我想得到g()的值 该怎么写f(l) = x(1) ^ 2 + x(2) ^ 2 - x(1) * x(2) - 10 * x(1) - 4 * x(2) + 60
这个函数用该怎么定义
g(1) = 11 - x(1) - x(2)
g(2) = 6 - x(1)
g(3) = 8 - x(2)
g(4) = x(1)
g(5) = x(2)
End Sub
在调用函数f时,我想得到g()的值 该怎么写f(l) = x(1) ^ 2 + x(2) ^ 2 - x(1) * x(2) - 10 * x(1) - 4 * x(2) + 60
这个函数用该怎么定义
这个函数 该怎么定义 调用的时候 该怎么写
Dim g(5) As Integer
Dim x(2) As Integer
Dim iFor i = 0 To 2
x(i) = i
Nextf g, xFor i = 0 To 5
Debug.Print g(i)
Next iMsgBox f1(x)
End Sub
Private Sub f(g() As Integer, x() As Integer)
g(1) = 11 - x(1) - x(2)
g(2) = 6 - x(1)
g(3) = 8 - x(2)
g(4) = x(1)
g(5) = x(2)
End SubPrivate Function f1(x() As Integer) As Integer
f1 = x(1) ^ 2 + x(2) ^ 2 - x(1) * x(2) - 10 * x(1) - 4 * x(2) + 60
End Function
第二个问题
private function f(x() as integer)
...
end function