2017年11月21日 星期二

[ VB2010 ] - 007 副程式流程001


[ VB2010 ] - 007 副程式流程001






Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        SubProg0001()
        SubProg0002()
    End Sub

    Sub SubProg0001()
        Dim A As String

        A = "Hello VB2010 World!"
        MsgBox(A)
    End Sub

    Sub SubProg0002()
        Dim A As String

        A = "歡迎進入VB2010 !"
        MsgBox(A)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim a1, a2 As Single
        a1 = SubProg0003()
        a2 = SubProg0004()
        TextBox1.Text = CStr(a1 + a2)

    End Sub

    Function SubProg0003() As Integer
        Dim a As Integer
        a = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10  '使用 Return 敘述傳回值
        TextBox2.Text = CStr(a)
        SubProg0003 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10  '使用 Return 敘述傳回值

    End Function

    Function SubProg0004() As Single
        Dim A As Single
        Dim B As Single

        A = 3.14159
        B = 1.1414
        SubProg0004 = A * B
        TextBox3.Text = CStr(A * B)

    End Function

End Class

沒有留言:

張貼留言

WOKWI LED + MQTT Node-Red SQLite

WOKWI LED + MQTT Node-Red SQLite const char *mqtt_broker = "broker.mqtt-dashboard.com" ; const char *topic1 = "alex9ufo/e...