Public Class Form1
Dim R As Integer
Dim G As Integer
Dim B As Integer
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
PictureBox4.BackColor = Color.FromArgb(TrackBar1.Value, TrackBar2.Value, TrackBar3.Value)
Label1.Text = TrackBar1.Value
PictureBox1.BackColor = Color.FromArgb(TrackBar1.Value, 0, 0)
End Sub
Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll
PictureBox4.BackColor = Color.FromArgb(TrackBar1.Value, TrackBar2.Value, TrackBar3.Value)
Label2.Text = TrackBar2.Value
PictureBox2.BackColor = Color.FromArgb(0, TrackBar2.Value, 0)
End Sub
Private Sub TrackBar3_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar3.Scroll
PictureBox4.BackColor = Color.FromArgb(TrackBar1.Value, TrackBar2.Value, TrackBar3.Value)
Label3.Text = TrackBar3.Value
PictureBox3.BackColor = Color.FromArgb(0, 0, TrackBar3.Value)
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))
TrackBar1.Value = R
TrackBar2.Value = G
TrackBar3.Value = B
PictureBox4.BackColor = Color.FromArgb(R, G, B)
Label1.Text = R
PictureBox1.BackColor = Color.FromArgb(R, 0, 0)
Label2.Text = G
PictureBox2.BackColor = Color.FromArgb(0, G, 0)
Label3.Text = B
PictureBox3.BackColor = Color.FromArgb(0, 0, B)
End Sub
End Class
沒有留言:
張貼留言