You are on page 1of 4

PROGRAM RGB

OBJEK Form PictureBox PictureBox PictureBox PictureBox text text text text Label1 Label2 Label3 Label4 CommanButton

PROPERTY Name caption Name Wideth Height Name Wideth Height Name Wideth Height Name Wideth Height Form1 Form1 Picture1 1335 1335 Picture2 1335 1335 Picture3 1335 1335 Picture4 1935 1935 Text1 Text2 Text3 Text4 Label R= Label2 G= Label3 B= Label4 RGB Command1

NILAI

name Name caption Name Caption Name Caption Name Caption Name

1. LISTING PROGRAM Private Sub Command1_Click() On Error Resume Next Picture4.BackColor = RGB(Text1.Text, Text2.Text, Text3.Text) Text4.Text = "( " & Text1.Text & ", " & Text2.Text & ", " & Text3.Text & " )" Text1.SetFocus End Sub Private Sub Form_Activate() Text1.SetFocus End Sub Private Sub Form_Load() Text4.Enabled = False End Sub

Private Sub Text1_Change() On Error Resume Next If Text1.Text = "" Then Picture1.BackColor = &H8000000F End If If Val(Text1.Text) > 255 Then MsgBox "Nilai yang Anda input melebihi jangkauan, yaitu 255", vbOKOnly + vbCritical, "Konfirmasi" Picture1.BackColor = &H8000000F Text1.Text = "" Text1.SetFocus ElseIf Val(Text1.Text) <= 255 Then Picture1.BackColor = RGB(Text1.Text, &O0, &O0) End If End Sub Private Sub Text2_Change() On Error Resume Next If Text1.Text = "" Then Picture1.BackColor = &H8000000F End If If Val(Text2.Text) > 255 Then MsgBox "Nilai yang Anda input melebihi jangkauan, yaitu 255", vbOKOnly + vbCritical, "Konfirmasi" Picture2.BackColor = &H8000000F Text2.Text = "" Text2.SetFocus ElseIf Val(Text2.Text) <= 255 Then Picture2.BackColor = RGB(&O0, Text2.Text, &O0) End If End Sub Private Sub Text3_Change() On Error Resume Next If Text1.Text = "" Then Picture1.BackColor = &H8000000F End If If Val(Text3.Text) > 255 Then MsgBox "Nilai yang Anda input melebihi jangkauan, yaitu 255", vbOKOnly + vbCritical, "Konfirmasi" Picture3.BackColor = &H8000000F Text3.Text = "" Text3.SetFocus ElseIf Val(Text3.Text) <= 255 Then Picture3.BackColor = RGB(&O0, &O0, Text3.Text) End If

End Sub Private Sub Text3_LostFocus() If Text3.Text <> "" Then Command1.SetFocus End If End Sub