0

I am really annoyed here. I don't understand why this event keeps throwing a blank error. Below is my code.

Private Sub cboSections_SelectedChangeCommitted(sender As System.Object, e As System.EventArgs) Handles cboSections.SelectionChangeCommitted
    On Error GoTo EH

    If TypeOf sender Is Windows.Forms.ComboBox Then
        'some boolean that checks if we are skipping this event, thus it does if so
        If mbSkipEvent Then Exit Sub

        'checks if index that was changed to is > 0 then it toggles the bottom command buttons
        If cboSections.SelectedIndex > 0 Then
            ToggleCmdButtons(True)
        Else
            ToggleCmdButtons(False)
        End If

        'sets the string msPurpose
        msPurpose = "Show Section"
        Debug.Print("Im here")
    End If
EH:
    Debug.Print("Error Description: " & Err.Description)
End Sub

In my output I get "Error Description: ". Thats it. If anyone has any solution or point in the right direction that would be great.

4

1 回答 1

1

Let's try some real error handling and see if you get anything better. While we're at it, we can simplify the code a bit:

Private Sub cboSections_SelectedChangeCommitted(sender As System.Object, e As System.EventArgs) Handles cboSections.SelectionChangeCommitted
    Dim comboBox = TryCast(sender, ComboBox)
    If comboBox Is Nothing OrElse mbSkipEvent Then Exit Sub
    Try
       'checks if index that was changed to is > 0 then it toggles the bottom command buttons
       ToggleCmdButtons(cboSections.SelectedIndex > 0)

       'sets the string msPurpose
        msPurpose = "Show Section"
        Debug.Print("Im here")
    Catch Ex As Exception
        Debug.Print("Error Description: " & Ex.Message)
    End Try
End Sub
于 2013-10-23T15:12:00.353 回答