www.JosXP.com, Joomla Professionals

Color Name: 

Category:  Graphic

Very useful class which converts the color name to known color name, this class contains 140 color names.

The class clsColorName contains the following events and properties:

Events:

OnNotFound():

Fired when the user asks for unknown color using the property Name2Color

OnFill(ColorName As String, ColorCode As Long, ColorIndex As Integer)

Fired 140 times when the user call the method Fill(), used to fill a ComboList or ListBox.

ColorName: returns the color name (i.e. yellow)
ColorCode: returns the color code (Me.backcolor = ColorCode)
ColorIndex: returns the color index (from 0 to 139)

The following example demonstrates how to use the class clsColorName

Dim WithEvents objColorName As clsColorName
Set objColorName = New clsColorName
objColorName.Fill 'This method will raise the event OnFill 140 times

Private Sub objColorName_OnFill(ColorName As String, ColorCode As Long, ColorIndex As Integer)
    cboColor.AddItem ColorName, ColorIndex 'Fill The ComboBox
    cboColor.ItemData(ColorIndex) = ColorCode
End Sub

You can use the color name:

Me.BackColor = objColorName.Name2Color("OrangeRed")




Trick Never Seen Before!