Option Explicit Dim N As Integer Private Sub Command1_Click() Dim A As Integer, B As Integer A = 2: B = 3 For N = 1 To 6 If N Mod 2 = 0 Then B = Fun(N, A) + A Else A = Fun(B, N) + B End If Next N Print N, A, B End Sub Private Function Fun(X As Integer, Y As Integer) As Integer X = Y - 1 + N Y = X + Y - N Fun = X + Y End Function
ÆäʵÄã¿ÉÒԶϵãdebugϾÍÖªµÀÁË Private Function Fun(ByVal X As Integer, ByVal Y As Integer) As Integer X = Y - 1 + N Y = X + Y - N Fun = X + Y End Function ¾ÍÊÇÕâ¸öÔÒò¡£ VBÖУ¬±äÁ¿µÄ´«µÝĬÈÏÊÇ ByRef µÄ¡£