如何用VB 做交通號誌的程式

如何VB設計一個手動交通號誌。

輸出要求:

a. 當沒有按下任何滑鼠鍵時,顯示綠燈。

b. 當按住滑鼠左鍵時,顯示黃燈。

c. 當按住滑鼠右鍵或中鍵(或滾輪)時,顯示紅燈。

d. 當滑鼠鍵放開時,顯示綠燈。

1 個解答

評分
  • 8 年前
    最佳解答

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    OvalShape1.BackColor = Color.Green

    End Sub

    Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown

    OvalShape1.BackStyle = PowerPacks.BackStyle.Opaque

    If e.Button = Windows.Forms.MouseButtons.Left Then OvalShape1.BackColor = Color.Yellow

    If e.Button = Windows.Forms.MouseButtons.Middle Then OvalShape1.BackColor = Color.Red

    If e.Button = Windows.Forms.MouseButtons.Right Then OvalShape1.BackColor = Color.Red

    End Sub

    Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp

    OvalShape1.BackColor = Color.Green

    End Sub

    參考資料: me
    • 登入以對解答發表意見
還有問題?馬上發問,尋求解答。