Converting Color chooser color to html hex

pcmantinker

New member
Joined
Feb 25, 2007
Messages
3
Programming Experience
1-3
I am making an application in VB .NET 2005 that requires me to convert the colors I choose from the color chooser dialog to HTML hex. I know how to do this in VB 6, but I get an error that the color can not be converted to hex.

Here is the error I get:
Argument 'Number' cannot be converted to type 'Color'.

Here is the code I am using:
VB.NET:
Private Sub pick_color()
        ColorDialog1.ShowDialog()
        'converts color to hex and puts it in a text box
        primarybg.Text = "#" & Hex(ColorDialog1.Color)
End Sub
In Visual Basic 6, this method would work (with slightly different code), but I am unsure of why the error occurs in VB .NET.
 
VB.NET:
primarybg.Text = ColorTranslator.ToHtml(ColorDialog1.Color)
 
Back
Top