Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SerialPort1.BaudRate = 9600 SerialPort1.DataBits = 8 SerialPort1.Parity = IO.Ports.Parity.None SerialPort1.StopBits = IO.Ports.StopBits.One SerialPort1.PortName = "COM3" SerialPort1.Open() TextBox_R.Text = 0 TextBox_G.Text = 0 TextBox_B.Text = 0 TextBox_RGB.Text = 0 '( 1000000000 + R*1000000 + G*1000 + B) TextBox_RGB.Hide() End Sub Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar_R.Scroll TextBox_R.Text = TrackBar_R.Value Panel1.BackColor = System.Drawing.Color.FromArgb(TextBox_R.Text, TextBox_G.Text, TextBox_B.Text) End Sub Private Sub TrackBar2_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar_G.Scroll TextBox_G.Text = TrackBar_G.Value Panel1.BackColor = System.Drawing.Color.FromArgb(TextBox_R.Text, TextBox_G.Text, TextBox_B.Text) End Sub Private Sub TrackBar3_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar_B.Scroll TextBox_B.Text = TrackBar_B.Value Panel1.BackColor = System.Drawing.Color.FromArgb(TextBox_R.Text, TextBox_G.Text, TextBox_B.Text) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnviarDatos.Click TextBox_RGB.Text = 1000000000 + TextBox_R.Text * 1000000 + TextBox_G.Text * 1000 + TextBox_B.Text SerialPort1.Write(TextBox_RGB.Text) 'System.Threading.Thread.Sleep(200) 'TextBox5.Text = SerialPort1.ReadExisting() End Sub Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint End Sub Private ClD As New ColorDialog Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If ClD.ShowDialog = Windows.Forms.DialogResult.OK Then Panel1.BackColor = ClD.Color Dim tmpBrush As New SolidBrush(Panel1.BackColor) With tmpBrush.Color TextBox_B.Text = .B TextBox_G.Text = .G TextBox_R.Text = .R TrackBar_R.Value = TextBox_R.Text TrackBar_G.Value = TextBox_G.Text TrackBar_B.Value = TextBox_B.Text End With 'Without the With statement, you need to put in: 'for example. End If End Sub Private Sub Delet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Delet.Click Panel1.BackColor = Color.Black TextBox_B.Text = 0 TextBox_G.Text = 0 TextBox_R.Text = 0 TrackBar_R.Value = 0 TrackBar_G.Value = 0 TrackBar_B.Value = 0 SerialPort1.Write(1000000000) End Sub End Class