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
Call SetColor(R, G, B)
End Sub
Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar2.Scroll
G = TrackBar2.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
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
A = MsgBox("您的色彩有" + " 紅色=" & R & " 綠色=" & G & " 藍色=" & B, MsgBoxStyle.YesNo + MsgBoxStyle.Information, "調色盤")
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
R = TrackBar1.Value + 10
Call SetColor(R, G, B)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
R = TrackBar1.Value + 1
Call SetColor(R, G, B)
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
R = TrackBar1.Value - 1
Call SetColor(R, G, B)
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
R = TrackBar1.Value - 10
Call SetColor(R, G, B)
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
G = TrackBar2.Value + 10
Call SetColor(R, G, B)
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
G = TrackBar2.Value + 1
Call SetColor(R, G, B)
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
G = TrackBar2.Value - 1
Call SetColor(R, G, B)
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
G = TrackBar2.Value - 10
Call SetColor(R, G, B)
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
B = TrackBar3.Value + 10
Call SetColor(R, G, B)
End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
B = TrackBar3.Value + 1
Call SetColor(R, G, B)
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
B = TrackBar3.Value - 1
Call SetColor(R, G, B)
End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
B = TrackBar3.Value - 10
Call SetColor(R, G, B)
End Sub
Sub SetColor(ByRef R As Integer, ByRef G As Integer, ByRef B As Integer)
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
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(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
R = TrackBar1.Value
G = TrackBar2.Value
B = TrackBar3.Value
Call SetColor()
End Sub
End Class
作者已經移除這則留言。
回覆刪除???
刪除..
回覆刪除..
...
回覆刪除???
刪除作者已經移除這則留言。
回覆刪除???
刪除