none
How do I retrieve RGB values from the Colorpicker in VB2017? RRS feed

  • Question

  • I am designing an instrument for my student and have a working tool that shown how to use the colorpicker tool. In order to use the color values in the project, I have to write them and install them into the code.

    I really hope there is a way to make this information to be sent directly into variables.

    Is there?

    I checked a few VB web sites but the explanations don't seem to cover this.

    Sunday, July 9, 2017 4:52 PM

All replies

  • Have you tried ColorDialog.Color.R, ColorDialog.Color.G, ColorDialog.Color.B and ColorDialog.ToArgb? This assume you are working in a Windows Forms project.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Sunday, July 9, 2017 6:02 PM
    Moderator
  • Hi carolBz,

    Please refer to:

    Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
            Dim cDialog As New ColorDialog()
            cDialog.Color = Label1.BackColor ' initial selection is current color.
    
            If (cDialog.ShowDialog() = DialogResult.OK) Then
                Label1.BackColor = cDialog.Color ' update with user selected color.
                Console.WriteLine(cDialog.Color.R & " " & cDialog.Color.G & " " & cDialog.Color.B & " " & cDialog.Color.ToArgb)
            End If
    
        End Sub

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, July 10, 2017 8:48 AM
    Moderator
  • Hi carolBz,

    Please remember to close your thread by marking the helpful post as answer, it is very beneficial to other community members who face the same issue.

    Thanks for your understanding.

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, July 19, 2017 7:31 AM
    Moderator