2019年4月9日 星期二

調色盤ColorV6



Public Class Form1

    Dim R As Integer
    Dim G As Integer
    Dim B As Integer
    Dim A As Integer

    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        R = TrackBar1.Value
        G = TrackBar2.Value
        B = TrackBar3.Value
        Call SetColor(R, G, B)
    End Sub

    Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll
        R = TrackBar1.Value
        G = TrackBar2.Value
        B = TrackBar3.Value
        Call SetColor(R, G, B)
    End Sub

    Private Sub TrackBar3_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar3.Scroll
        R = TrackBar1.Value
        G = TrackBar2.Value
        B = TrackBar3.Value
        Call SetColor(R, G, B)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        R = val(InputBox("請輸入紅色", "紅", 128))
        G = val(InputBox("請輸入綠色", "綠", 128))
        B = val(InputBox("請輸入藍色", "藍", 128))
        Call SetColor(R, G, B)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        R = Val(TextBox1.Text)
        G = Val(TextBox2.Text)
        B = Val(TextBox3.Text)
        Call SetColor(R, G, B)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        R = TrackBar1.Value
        G = TrackBar2.Value
        B = TrackBar3.Value
        A = MsgBox("您的色彩有" + "  紅色=" & R & "  綠色=" & G & "  藍色=" & B, MsgBoxStyle.YesNo + MsgBoxStyle.Information, "調色盤")
    End Sub

    Sub SetColor(ByRef R As Integer, ByRef G As Integer, ByRef B As Integer)
        TrackBar1.Value = R
        TrackBar2.Value = G
        TrackBar3.Value = B

        Label1.Text = R

        Label2.Text = G
        Label3.Text = B

        TextBox1.Text = R

        TextBox2.Text = G
        TextBox3.Text = B

        PictureBox1.BackColor = Color.FromArgb(R, 0, 0)

        PictureBox2.BackColor = Color.FromArgb(0, G, 0)
        PictureBox3.BackColor = Color.FromArgb(0, 0, B)

        PictureBox4.BackColor = Color.FromArgb(R, G, B)

    End Sub

End Class

23 則留言:

  1. 哈哈哈哈哈阿哈阿哈哈哈哈阿哈阿哈哈哈 阿阿哈阿

    回覆刪除
  2. 回覆
    1. 嗯!
      要瞭解每一行指令的原因和理由!

      刪除
  3. 作者已經移除這則留言。

    回覆刪除
  4. 作者已經移除這則留言。

    回覆刪除
  5. 作者已經移除這則留言。

    回覆刪除