Public Class Form1
Dim R As Integer
Dim G As Integer
Dim B As Integer
Dim A As Integer
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
R = Val(InputBox("請輸入紅色", "紅", 128))
G = Val(InputBox("請輸入綠色", "綠", 128))
B = Val(InputBox("請輸入藍色", "藍", 128))
Call SetColor()
End Sub
Private Sub TrackBar1_Scroll(sender As Object, e As EventArgs) Handles TrackBar1.Scroll
R = TrackBar1.Value
Call SetColor()
End Sub
Private Sub TrackBar2_Scroll(sender As Object, e As EventArgs) Handles TrackBar2.Scroll
G = TrackBar2.Value
Call SetColor()
End Sub
Private Sub TrackBar3_Scroll(sender As Object, e As EventArgs) Handles TrackBar3.Scroll
B = TrackBar3.Value
Call SetColor()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
R = Val(TextBox1.Text)
G = Val(TextBox2.Text)
B = Val(TextBox3.Text)
Call SetColor()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
A = MsgBox("您的色彩有" + " 紅色=" & R & " 綠色=" & G & " 藍色=" & B, MsgBoxStyle.YesNo + MsgBoxStyle.Information, "調色盤")
End Sub
Sub SetColor()
If R > 255 Then
R = 255
ElseIf R < 0 Then
R = 0
End If
If G > 255 Then
G = 255
ElseIf G < 0 Then
G = 0
End If
If B > 255 Then
B = 255
ElseIf B < 0 Then
B = 0
End If
TrackBar1.Value = R
TrackBar2.Value = G
TrackBar3.Value = B
HScrollBar1.Value = R
HScrollBar2.Value = G
HScrollBar3.Value = B
VScrollBar1.Value = R
VScrollBar2.Value = G
VScrollBar3.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
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
R = TrackBar1.Value
G = TrackBar2.Value
B = TrackBar3.Value
Call SetColor()
End Sub
Private Sub HScrollBar1_Scroll(sender As Object, e As ScrollEventArgs) Handles HScrollBar1.Scroll
R = HScrollBar1.Value
Call SetColor()
End Sub
Private Sub HScrollBar2_Scroll(sender As Object, e As ScrollEventArgs) Handles HScrollBar2.Scroll
G = HScrollBar2.Value
Call SetColor()
End Sub
Private Sub HScrollBar3_Scroll(sender As Object, e As ScrollEventArgs) Handles HScrollBar3.Scroll
B = HScrollBar3.Value
Call SetColor()
End Sub
Private Sub VScrollBar1_Scroll(sender As Object, e As ScrollEventArgs) Handles VScrollBar1.Scroll
R = VScrollBar1.Value
Call SetColor()
End Sub
Private Sub VScrollBar2_Scroll(sender As Object, e As ScrollEventArgs) Handles VScrollBar2.Scroll
G = VScrollBar2.Value
Call SetColor()
End Sub
Private Sub VScrollBar3_Scroll(sender As Object, e As ScrollEventArgs) Handles VScrollBar3.Scroll
B = VScrollBar3.Value
Call SetColor()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
R = TrackBar1.Value + 10
Call SetColor()
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
R = TrackBar1.Value + 1
Call SetColor()
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
R = TrackBar1.Value - 1
Call SetColor()
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
R = TrackBar1.Value - 10
Call SetColor()
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
G = TrackBar2.Value + 10
Call SetColor()
End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
G = TrackBar2.Value + 1
Call SetColor()
End Sub
Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
G = TrackBar2.Value - 1
Call SetColor()
End Sub
Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
G = TrackBar2.Value - 10
Call SetColor()
End Sub
Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
B = TrackBar3.Value + 10
Call SetColor()
End Sub
Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
B = TrackBar3.Value + 1
Call SetColor()
End Sub
Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
B = TrackBar3.Value - 1
Call SetColor()
End Sub
Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
B = TrackBar3.Value - 10
Call SetColor()
End Sub
End Class