Color Picker sample


This is a Color Picker sample in Visual Basic 6.

You have seen color picker tools in many software applications like in photo editing software, web designing environment and in other applications. The Visual Basic 6 IDE also offers a color picker tool to set different color properties like BackColor, ForeColor etc. But the color picker tool given in the VB IDE is outdated as it shows you only the old colors which means these colors were used before even Windows XP was there. So you won't get all the modern colors.

So the Color Picker app will show you all the modern colors along with their hexa-decimal code which you can easily copy and use in your VB program. Another feature of this tool is that the hex-color-code is automatically copied to the clipboard after you pick a color. Therefore you can graphically enhance your app with this tool.



                                                             >> DOWNLOAD 



Screenshot:

Color Dialog Window


program to pick color, a color picker tool





How to design?

Take a text box txtHex, two command buttons cmdCopy and cmdPickAnotherColor, a CommonDialog control, and lastly a shape shpColor. Now you may choose an icon for the form. Set a suitable icon using the Icon property of the form.


Code:

'Declarations section
Dim C As Long
Dim S As String
____________________________________________________
Private Sub cmdCopy_Click()
    Clipboard.SetText (S)
End Sub
____________________________________________________
Private Sub cmdPickAnotherColor_Click()
    Call Form_Load
End Sub
____________________________________________________
Private Sub Form_Load()
    CommonDialog1.ShowColor
    C = CommonDialog1.Color
    S = Hex(C)
  
    While Len(S) < 6
        S = "0" + S
    Wend
  
    S = "&H00" + S + "&"
  
    txtHex.Text = S
    shpColor.BackColor = Val(S)
    Clipboard.SetText (S)
End Sub

____________________________________________________
Private Sub txtHex_GotFocus()
    txtHex.SelStart = 0
    txtHex.SelLength = 9999
End Sub