Question toargb from argb

gripper

New member
Joined
Aug 20, 2013
Messages
1
Programming Experience
10+
Hi I have the following code

Dim cFromColour As Color
Dim sFromColour As String = "Cyan"
Dim iFromInt As Integer = 0

Dim cToColour As Color
Dim sToColour As String

cFromColour = System.Drawing.Color.FromName(CStr(sFromColour))
iFromInt = cFromColour.ToArgb

cToColour = Color.FromArgb(iFromInt)
sToColour = cToColour.Name

iFromInt = -16711681

when I do the fromargb

cToColour = "{Name=ff00ffff, ARGB=(255, 0, 255, 255)}"

and not cyan

Can anyone help please

Thanks
 
You can only get named colors for those created by FromKnownColor or FromName, if you convert to other kind of value the name is lost. If you want to preserve that name to/from strings you can use ColorTranslator class and ToHtml/FromHtml methods, non-named colors will then return hex values.
 
Back
Top