2017年10月12日 星期四

第 3 章 小小電子琴 Sub ...End Sub 寫法


第 3 章 小小電子琴




Public Class Form1
    Sub Do_1()
        Console.Beep(262, 500)
    End Sub

    Sub Re_1()
        Console.Beep(294, 500)
    End Sub

    Sub Mi_1()
        Console.Beep(330, 500)
    End Sub

    Sub Fa_1()
        Console.Beep(349, 500)
    End Sub

    Sub Sol_1()
        Console.Beep(392, 500)
    End Sub
    Sub La_1()
        Console.Beep(440, 500)
    End Sub
    Sub Si_1()
        Console.Beep(494, 500)
    End Sub
    Sub Do_()
        Console.Beep(523, 500)
    End Sub

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

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles Button2.Click
        Do_1()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles Button3.Click
        Mi_1()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles Button4.Click
        Fa_1()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles Button5.Click
        Sol_1()
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles Button6.Click
        La_1()
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles Button7.Click
        Si_1()
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles Button8.Click
        Do_()
    End Sub

    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) _
    Handles Me.KeyDown
        Select Case e.KeyCode
            Case Keys.D1 : Console.Beep(262, 500)
            Case Keys.D2 : Console.Beep(294, 500)
            Case Keys.D3 : Console.Beep(330, 500)
            Case Keys.D4 : Console.Beep(349, 500)
            Case Keys.D5 : Console.Beep(392, 500)
            Case Keys.D6 : Console.Beep(440, 500)
            Case Keys.D7 : Console.Beep(493, 500)
            Case Keys.D8 : Console.Beep(523, 500)
            Case Else : Exit Sub
        End Select
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles Timer1.Tick
        Label1.Text = Now.ToString
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles MyBase.Load
        Label1.Text = Now.ToString
        Label2.Text = WeekdayName(Weekday(Now))
        Label1.Left = (Me.ClientSize.Width - Label1.Width) / 2
        Timer1.Start()
    End Sub
End Class

沒有留言:

張貼留言

113 學年度第 1 學期 RFID應用課程 Arduino程式

113 學年度第 1 學期 RFID應用課程 Arduino程式 https://www.mediafire.com/file/zr0h0p3iosq12jw/MFRC522+(2).7z/file 內含修改過後的 MFRC522 程式庫 (原程式有錯誤) //定義MFRC522...