Hello, I have made my program but I want to give users the option of choosing a custom color for text. I have an inputbox that works and then converts it to Color.whatever. But seeing as the user types in what they want and it is not done by the program itself it can throw exceptions.

Dim directresponse As String
        Dim actualcolor As String
        Dim isgood As Boolean
        directresponse = InputBox("Choose a custom color to be displayed! Example for " & Chr(34) & "Red" & Chr(34) & " type " & Chr(34) & "Red" & Chr(34), "SimpleTimer: Choose A Color")
        actualcolor = "Color." + directresponse
        If actualcolor = (System.ComponentModel.TypeDescriptor) Then
        End If

That is my Sub, it will make Color.(userinput) but I need to check if Color.(userinput) is actually a color that VB.NET can understand and add set. I have tried "System.Drawing.Color" I get told it is a type and cannot be used in this context. VB.NET help suggested to use System.ComponentModel.TypeDescriptor to convert it to a color and check if it is real and then set it.


7 Years
Discussion Span
Last Post by __avd
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.