2017年11月21日 星期二

[ VB2010 ] - 007 副程式流程004

[ VB2010 ] - 007 副程式流程004


●副程式內呼叫副程式:

●副程式傳出結果成為另一個副程式的引數:

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

沒有留言:

張貼留言

2024_09 作業3 以Node-Red 為主

 2024_09 作業3  (以Node-Red 為主  Arduino 可能需要配合修改 ) Arduino 可能需要修改的部分 1)mqtt broker  2) 主題Topic (發行 接收) 3) WIFI ssid , password const char br...