Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

string.Format

 

Ignoring the alpha component:

 

string str = string.Format("#{0:x6}", color.ToArgb() & 0x00ffffff);

 

Or in VB:

 

Dim str As String = String.Format("#{0:x6}", color.ToArgb() And &H00FFFFFF)

 

Good luck :cool:

Never trouble another for what you can do for yourself.
Posted

Well, I think I was unable to clarify myself.

I have a color in HTML format, like #ffffff for example.

I wanna convert it to standard System.Drawing.Color format.

So input is string, but output is NOT, output is RGB color format.

Thanks.

Posted

Open wide...

 

I wonder how many other people misinterpreted your post... never mind.

 

Assuming the string is exactly the format "#ffffff", then this would work:

 

color = Color.FromArgb(int.Parse(htmlString.Substring(1), System.Globalization.NumberStyles.HexNumber));

 

Information on all these types and methods are available in the MSDN help, and in the Object Browser. I suggest you use them.

 

Good luck :cool:

Never trouble another for what you can do for yourself.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...