|
-
Jun 8th, 2001, 04:45 PM
#1
Color values
Hi there
Is there a way that the rgb color values be returned and places withing a rgb() statement?
thanx
-
Jun 8th, 2001, 04:46 PM
#2
Returned form a color dialog box?
-
Jun 8th, 2001, 04:56 PM
#3
Registered User
you mean the rgb values out of the standard returned color numbers?
Standrad would be like
commondialog1.showcolor
color = commondialog1.color
-
Jun 8th, 2001, 05:00 PM
#4
yes
kinda like say Rgb(X,Y,Z) if a rnd color is click on the dialogbox
-
Jun 8th, 2001, 05:04 PM
#5
Registered User
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
Last edited by Olly; Jun 8th, 2001 at 05:12 PM.
-
Jun 8th, 2001, 05:09 PM
#6
Registered User
I got it! :)
Add this function to a Module:
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
To use this code add the following lines to a form:
Code:
Command1_Click()
Dim RGBVal as String
RGBVal = gfnLongToRGBString(SYSCol)
End Sub
SYSCol is the system color (Long value) like &H0 (Black). RGBVal will be set to "000000" (Black)
-
Jun 8th, 2001, 05:13 PM
#7
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??
-
Jun 8th, 2001, 05:20 PM
#8
Registered User
Code:
Private Sub VScroll1_Change(index As Integer)
RichTextBox1.SelColor = RGB(VScroll1(0).Value, VScroll1(1).Value, VScroll1(2).Value)
End Sub
{but your rtf box will lose its focus so better use the CommonDialog or some Coler listbox from vbaccelerator.com}
oh no, it works, it's all fine just thought for a moment
Last edited by Olly; Jun 8th, 2001 at 05:30 PM.
-
Jun 8th, 2001, 05:24 PM
#9
-
Jun 8th, 2001, 05:30 PM
#10
-
Jun 8th, 2001, 06:01 PM
#11
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
You can use the RGB() function too.
lColor = RGB(R, G, B)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|