Question[help]Convert String to Color[Solved]

Posts 1–11 of 11 · Page 1 of 1
[help]Convert String to Color[Solved]
So as all of you know, I'm working on my web browser, but I need YOUR help.

How do you convert string to color????????


example of a string:

Color [A=255, R=211, G=69, B=112]


so here is part of my code:


[php]
dim d as string
d = reader.readline()
colordialog1.color = d <----- need to convert
[/php]
Simple Man

[php] Dim red As String = "233"
Dim green As String = "133"
Dim blue As String = "44"
dim alpha as integer=255
Me.BackColor = Color.FromArgb(alpha, red, green, blue)
[/php]
MSDN:

Code:
Public Shared Function FromName( _
   ByVal name As String _
) As Color
name
A string that is the name of a pre-defined color. Valid names are the same as the names of the elements of the KnownColor enumeration.
Return Value

The Color structure that this method creates.

Remarks

A pre-defined color is also called a known color and is represented by an element of the KnownColor enumeration. If name is not the valid name of a pre-defined color, the FromName method creates a Color structure that has an ARGB value of zero (that is, all ARGB components are 0).

Nextgen1

So unless I am misunderstanding what you want you can use the above and

[php]
Dim d as color
d = Color.Aqua ' Or whatever color
[/php]



Or you can use color from ARGB

Dim "whatever" As Color = Color.FromArgb("'RGB Here' 0,0,0")


[php]
Dim d As Color = Color.FromArgb(255, 255, 255)
' d = white
[/php]


close this plz i found a solution


Dim colorz As New ColorConverter
ColorDialog1.Color = colorz.ConvertFromString(d)
Already answered with that MJ (kinda)


marked Solved, left open for the community, I will close if members dump in it or post after 6 days, you may not be the only one experiencing this problem

Quote Originally Posted by NextGen1 View Post
Already answered with that MJ (kinda)


marked Solved, left open for the community, I will close if members dump in it or post after 6 days, you may not be the only one experiencing this problem

LOL, we both posted this the same time.
/sorry for double post

i get errors (opendialog1 dosent close)


[php]
Dim colorgod As New Color
Dim colorz As New ColorConverter
colorz.ConvertFromString(d)
colorgod = colorz.ConvertFromString(d)
Dim aa, bb, cc, dd As String
aa = colorgod.A
bb = colorgod.R
cc = colorgod.G
dd = colorgod.B
ColorDialog1.Color = Color.FromArgb(aa, bb, cc, dd)
[/php]
A. What is D declared as ?
d is declared as a string

teamviewer:

ID:
498 213 695
Pass:
asdfasdf
Posts 1–11 of 11 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us