Hi there
Is there a way that the rgb color values be returned and places withing a rgb() statement?
thanx:confused:
Printable View
Hi there
Is there a way that the rgb color values be returned and places withing a rgb() statement?
thanx:confused:
Returned form a color dialog box?
you mean the rgb values out of the standard returned color numbers?
Standrad would be like
commondialog1.showcolor
color = commondialog1.color
yes
kinda like say Rgb(X,Y,Z) if a rnd color is click on the dialogbox
code to convert a long into rgb:
Code:Private Sub Command1_Click()
R = Val(InputBox$("Red Value"))
B = Val(InputBox$("Blue Value"))
G = Val(InputBox$("Green Value"))
Lng$ = B * 65536 + G * 256 + R
MsgBox Lng$
End Sub
Add this function to a Module:
To use this code add the following lines to a form:Code:Option Explicit
Public Function gfnLongToRGBString(lColor As Long) As String
iRed = lColor Mod 256
iGreen = ((lColor And &HFF00) / 256&) Mod 256&
iBlue = (lColor And &HFF0000) / 65536
gfnLongToRGBString = Str$(iRed) & Str$(iGreen) & Str$(iBlue)
End Function
SYSCol is the system color (Long value) like &H0 (Black). RGBVal will be set to "000000" (Black)Code:Command1_Click()
Dim RGBVal as String
RGBVal = gfnLongToRGBString(SYSCol)
End Sub
Another question
I dont know if u can help me on this one
I'm trying to use that values within a scroll bar
Now what im doing is once the user has clicked the color option the text of a richedit contol changes...
Im using a scroll bar to change the color of the text by scrolling with it ...
when the user goes back the same text color must be shown that showed previously
any ideas??
{but your rtf box will lose its focus so better use the CommonDialog or some Coler listbox from vbaccelerator.com}Code:Private Sub VScroll1_Change(index As Integer)
RichTextBox1.SelColor = RGB(VScroll1(0).Value, VScroll1(1).Value, VScroll1(2).Value)
End Sub
oh no, it works, it's all fine ;) just thought for a moment
Thanx a million!!
no prob ;)
You can use the RGB() function too.Quote:
Originally posted by Olly
code to convert a long into rgb:
Code:Private Sub Command1_Click()
R = Val(InputBox$("Red Value"))
B = Val(InputBox$("Blue Value"))
G = Val(InputBox$("Green Value"))
Lng$ = B * 65536 + G * 256 + R
MsgBox Lng$
End Sub
lColor = RGB(R, G, B)