Re: Converting Text to Default Colors in VB.NET

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: James Westgate (jameswestgate_at_nospam.nospam)
Date: 10/01/04


Date: Fri, 1 Oct 2004 13:44:30 +0100

Terry,

Try the color.FromName static method. Obviously your xml colro scheme will
have to match the scheme defined but its pretty comprehensive

James

-- 
Create interactive diagrams and flowcharts with ERM Diagram at
http://www.crainiate.net
Take the ERM Tour at http://www.flowchartcontrol.com
"Terry" <Terry@discussions.microsoft.com> wrote in message 
news:2F9C7E79-F287-4B7F-9EC5-03D5D924CC81@microsoft.com...
>I have an XML file that has settings for my app.  Many of the settings
> involve color (i.e. <BackColor>Red</BackColor>).  The XML value is read 
> into
> a string, so I have a string called strBackColor with the value "Red". 
> Now I
> want to set the form to BackColor.Red.  How do I do this without having a
> giant SELECT like this...
>
> SELECT CASE strBackColor
> CASE "Red"
> Me.BackColor = Backcolor.Red
> CASE "Blue"
> Me.BackColor = Backcolor.Red
> ...
> END SELECT
>
> Acually, I want it to be part of a global shared method that I can use
> throughout my system, where I pass in a String and it returns the 
> color..like
>
> Me.BackColor = CStringToColor(strBackColor)
>
> Thanks for your help,
> Terry