string to color

  • Thread starter Thread starter matt
  • Start date Start date
M

matt

I'm pulling a value from an xml file which is a color. i then want to use
these value to change the color of text or the background. how can i
convert this string value to a color in vb.net?

thanks!
 
try this, load the string into a variable then do

dim strcolor as color

me.backcolor = color.fromstring(strcolor)
 
I'm pulling a value from an xml file which is a color
What is the format of the value? A color name? A red-green-blue value?
 
if you parsed the

Color.FromString() to a string, it would come out to :

Color [Color Name Here] ex:

Color [Blue]
 
hmmm, curious where your getting the fromstring function. Is this new in 2005?

Here is how I did it for my application in 2003 edition:
Saving the Color as an integer
Dim iColor As Integer
iColor = Me.BackColor.ToArgb

Reading the color value from XML as string or int.
Dim iColor As Integer = -5185306
or
sColor As String = "-5185306"
iColor = Integer.Parse(sColor)
Me.BackColor = Color.FromArgb(iColor)

Hope that helps...
sisnaz
 
matt said:
I'm pulling a value from an xml file which is a color. i then want to use
these value to change the color of text or the background. how can i
convert this string value to a color in vb.net?

'Color.FromName', 'Color.FromKnownColor', 'Color.FromArgb'.
 
Color.FromString() does not appear to be a member of the .NET Framework, but
rather a member of the CSS Color class.

Where are you getting FromString() from?
 
there we go, thats what i meant, thanks Herfried....teaches me to try and
help someone without checking myself first...
 
Back
Top