DNR
DNR

Reputation: 3736

How can I use "#FFFF00" in vb.net?

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

Answers (2)

Muhammad Akhtar
Muhammad Akhtar

Reputation: 52241

do like...

Label1.ForeColor = System.Drawing.Color.FromName("#FFFF00")

Upvotes: 3

Oded
Oded

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

Related Questions