Reputation: 3736
When I attempt to use label1.ForeColor="#FFFF00"
I get an error: "Specified cast is not valid."
How can I resolve this?
Upvotes: 0
Views: 237
Reputation: 52241
do like...
Label1.ForeColor = System.Drawing.Color.FromName("#FFFF00")
Upvotes: 3
Reputation: 499072
You can use the WebColorConverter
class.
It has a ConvertFromString
method that can be used like this:
Dim ColorString As String = "#FFFF00"
Dim Color_Converter As New ColorConverter
Dim ActualColor As Color = Color_Converter.ConvertFromString(ColorString)
Upvotes: 3