I have a function that turns a Hex string from a textBox into a integer value for colors. The issue is that I cannot get the function to execute.
I have a break point inside the function that says the following on execute: "No executable code is associated with this line"
This happens even when I replace:
cDialog.CustomColors = New Integer() {HexToColor1(tbHeader.Text)}
With:
Dim cat As Integer
cat = HexToColor1(tbHeader.Text)
Here is what the partial code looks like:
Dim cDialog As New ColorDialog()
Private Sub btnHeader_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHeader.Click
cDialog.CustomColors = New Integer() {HexToColor1(tbHeader.Text)}
End Sub
Private Function HexToColor1(ByVal hexString As String) As Integer
Dim actColor As Integer
Dim r, g, b As Integer
r = 0
g = 0
b = 0
If hexString.StartsWith("#") And hexString.Length = 7 Then
r = Val(hexString.Substring(1, 2))
g = Val(hexString.Substring(3, 2))
b = Val(hexString.Substring(5, 2))
actColor = r + g * 256 + b * 65536
Else
actColor = 0
End If
Return actColor
End Function
This happens even when the Function's scope is set to "Public"
EDIT:
I do not know wether this is a debugger issue or not. When removing the break point from inside the function the code still will not work.
Valfunction supposed to know that is has to convert a hex number if the number contains only digits from0to9? Try this instead:Dim c As Color = (New System.Web.UI.WebControls.WebColorConverter()).ConvertFromString("#0C1722")