title: Visual Basic 2013 Color to code
body: <p>I wanna make color selector, when picked color write color code to text box. I created color dialog and text boxes, how make a rgb and hex codes from picked color?</p>
  
  <p>I'm trying this code, but it have a problem:</p>
  
  <pre><code>TextBox1.Text = ColorDialog1.Color.R + ", " + ColorDialog1.Color.G + ", " + ColorDialog1.Color.B
  </code></pre>
  
  <p>Getting:</p>
  
  <blockquote>
    <p>An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
    Additional information: Conversion from string ", " to type 'Double' is not valid.</p>
  </blockquote>