Monday, June 14, 2010

COLOUR BOX USING COMBOX

Buzz It
AIM:To Display colours using combo box

CODE

Form 1
Dim i As Integer
Private Sub blue_Change()
colour.BackColor = RGB(Val(red.Text), Val(green.Text), Val(blue.Text))
colour.Caption = Chr(10) & Chr(10) & Chr(10) & Chr(10) & Chr(10) & "red="
& red.Text & Chr(10) & "green=" & green.Text & Chr(10) & "blue=" &
blue.Text
End Sub
Private Sub blue_Click()
colour.BackColor = RGB(Val(red.Text), Val(green.Text), Val(blue.Text))
colour.Caption = Chr(10) & Chr(10) & Chr(10) & Chr(10) & Chr(10) & "red="
& red.Text & Chr(10) & "green=" & green.Text & Chr(10) & "blue=" &
blue.Text
End Sub
Private Sub Form_Load()
For i = 0 To 255 Step 10
red.AddItem i
Next i
red.ListIndex = 1
For i = 0 To 255 Step 10
green.AddItem i
Next i
green.ListIndex = 1
For i = 0 To 255 Step 10
blue.AddItem i
Next i

blue.ListIndex = 1
redlabel.BackColor = RGB(255, 0, 0)
greenlabel.BackColor = RGB(0, 255, 0)
bluelabel.BackColor = RGB(0, 0, 255)
colour.BackColor = RGB(Val(red.Text), Val(green.Text), Val(blue.Text))
colour.Caption = Chr(10) & Chr(10) & Chr(10) & Chr(10) & Chr(10) & "red="
& red.Text & Chr(10) & "green=" & green.Text & Chr(10) & "blue=" &
blue.Text
End Sub
Private Sub green_Change()
colour.BackColor = RGB(Val(red.Text), Val(green.Text), Val(blue.Text))
colour.Caption = Chr(10) & Chr(10) & Chr(10) & Chr(10) & Chr(10) & "red="
& red.Text & Chr(10) & "green=" & green.Text & Chr(10) & "blue=" &
blue.Text
End Sub
Private Sub green_Click()
colour.BackColor = RGB(Val(red.Text), Val(green.Text), Val(blue.Text))
colour.Caption = Chr(10) & Chr(10) & Chr(10) & Chr(10) & Chr(10) & "red="
& red.Text & Chr(10) & "green=" & green.Text & Chr(10) & "blue=" &
blue.Text
End Sub
Private Sub red_Change()
colour.BackColor = RGB(Val(red.Text), Val(green.Text), Val(blue.Text))
colour.Caption = Chr(10) & Chr(10) & Chr(10) & Chr(10) & Chr(10) & "red="
& red.Text & Chr(10) & "green=" & green.Text & Chr(10) & "blue=" &
blue.Text
End Sub
Private Sub red_Click()
colour.BackColor = RGB(Val(red.Text), Val(green.Text), Val(blue.Text))
colour.Caption = Chr(10) & Chr(10) & Chr(10) & Chr(10) & Chr(10) & "red="
& red.Text & Chr(10) & "green=" & green.Text & Chr(10) & "blue=" &
blue.Text
End Sub


0 comments:

Post a Comment