-
Color to hex
I'm not finding the correct syntax. This is what I have...
Code:
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
If Pathstr <> "" Then
Dim bitmap As New Bitmap(Pathstr)
Dim LocalMousePosition As Point
LocalMousePosition = PictureBox1.PointToClient(Cursor.Position)
bgc = bitmap.GetPixel(LocalMousePosition.X, LocalMousePosition.Y)
Label12.BackColor = bgc
Else
MsgBox("Please Drop an image before choosing color")
End If
ColorDialog1.Color = bgc
ColorDialog1.FullOpen = True
If ColorDialog1.ShowDialog <> Windows.Forms.DialogResult.Cancel Then
Label12.BackColor = ColorDialog1.Color
End If
Dim intColor2Dec As Integer
intColor2Dec = Convert.ToInt32(bgc)
TextBox1.Text = Microsoft.VisualBasic.Conversion.Hex(intColor2Dec)
End Sub
The Bold is where I am failing to convert to hex. What can I do to get this right?
-
Re: Color to hex
Well, bgc is a color, which has a .ToARGB method, which returns an integer, that can be converted to a string with .ToString("X"), so it seems like all you'd need is:
TextBox1.Text = bgc.ToARGB.ToString("X")
I haven't tried it, though.
-
Re: Color to hex