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

沒有留言:

張貼留言

零成本學 ESP32!在 Wokwi 打造你的第一個微型氣象站 (ESP32 + DHT22 + 1602 LCD)

零成本學 ESP32!在 Wokwi 打造你的第一個微型氣象站(溫度 濕度) (ESP32 + DHT22 + 1602 LCD) 想學物聯網(IoT)與 ESP32 電子實作,卻擔心接線與電壓規範搞砸嗎?透過強大的線上模擬器 Wokwi ,我們不需要花費任何硬體費用,打開瀏覽器...