●副程式內呼叫副程式:
●副程式傳出結果成為另一個副程式的引數:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox4.Text = CStr(X(4))
End Sub
Function X(ByVal Param1 As Integer) As Integer
TextBox1.Text = CStr(Param1)
Return Param1 * Y(Param1 + 1)
End Function
Function Y(ByVal Param1 As Integer) As Integer
TextBox2.Text = CStr(Param1)
Return Param1 * Z(Param1 + 1)
End Function
Function Z(ByVal Param1 As Integer) As Integer
TextBox3.Text = CStr(Param1)
Return Param1
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox4.Text = CStr(X1(Y1(Z1(2))))
End Sub
Function X1(ByVal Param1 As Integer) As Integer
TextBox3.Text = CStr(Param1)
Return Param1 * (Param1 + 1)
End Function
Function Y1(ByVal Param1 As Integer) As Integer
TextBox2.Text = CStr(Param1)
Return Param1 * (Param1 + 1)
End Function
Function Z1(ByVal Param1 As Integer) As Integer
TextBox1.Text = CStr(Param1)
Return Param1
End Function
End Class
沒有留言:
張貼留言