Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to create a circle on a screen from code and have the user change the color of the circle by using Scroll controls to assign values to A, R, G, and B in the Color.FromArgb(A, R, G, B) expression.
I would like to assign Rcolor = Color.FromArgb(A, R, G, B).

Here is my code snippet:
VB
Public Sub MakeCircle ()

Dim ShowCircles As Graphics
Dim PenColorR As New Pen(Color.Red)
ShowCircles = Me.CreateGraphics 
ShowCircles.DrawEllipse(PenColorR, 430 - AdjSepH, 450, 68, 86)  

The above code actually works, creating a red circle on the screen.
This also works:

Dim PenColorR As New Pen(Color.FromArgb(255, 255, 0, 0))

BUT, if I try to assign FromArgb to a variable like so, error messages are triggered...
VB
<br />
Dim Rcolor As Color = Color.FromArgb(255, 255, 0, 0)<br />
Dim PenColorR As New Pen(Color.Rcolor)

Or
Dim PenColorR As New Pen(Rcolor)

So is there way to assign Color.FromArgb(255, 255, 0, 0) to a variable (Rcolor) and use to color the graphics???

Hope this question is clear!!
Thanks
Gary Vogel
Posted
Updated 28-Oct-10 16:18pm
v2
Comments
DaveAuld 28-Oct-10 22:19pm    
Edit: Add code formatting

Your code below shouldn't trigger any error.

VB
Dim Rcolor As Color = Color.FromArgb(255, 255, 0, 0)
Dim PenColorR As New Pen(Rcolor)
 
Share this answer
 
How embarrassing is this?? I swear by the VB10 Gods that I tried
Dim PenColorR as New Pen(Rcolor)
several times last time and it would not work...cryptic error messages!!!
Somehow this morning, you are right...it worked!!!

So thanks for keeping me on the right path!!
Gary V
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900