How to Mix colors
Posted on January 5, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 'Graphics - How to Mix colors Option Explicit Private Function MixColors(ParamArray lMix() As Variant) As Long Dim lR As Long, lG As Long, lB As Long Dim lNewR As Long, lNewG As Long, lNewB As Long Dim lColors() As Long Dim I As Integer ReDim lColors(UBound(lMix) + 1) For I = 0 To UBound(lMix) lColors(I) = lMix(I) Next I For I = 0 To UBound(lColors) Debug.Print lColors(I) lR = lColors(I) And 255 lG = (lColors(I) And 65280) / 256 lB = (lColors(I) And 16711680) / 65536 lNewR = lNewR + lR lNewG = lNewG + lG lNewB = lNewB + lB Next I MixColors = RGB(lNewR / UBound(lColors) + 1, lNewG / UBound(lColors) + 1, _ lNewB / UBound(lColors) + 1) End Function 'How to use this function: 'Me.BackColor = MixColors(vbRed, vbYellow) 'produces an orange color |
Related posts:
- How to Convert OLE colors to RGB colors
- How to make a Web Browser in Visual Basic 2008 part 2 of 2
- How to get the RGB value of a Color
- How to get the Pixel color outside your form
- How to converte color value(longint) into RGB value.
- How to replace a Color with another Color in Picture Box
- How to delete an item in an array
- How to color the words in Rich Text box automatically like VB Editor?
- How to change the background color of each of your TextBox controls to yellow when it receives the input focus and restore its background color to white when the user clicks on another field