I have a form with a combobox that I added the validating event to verify the user has input a value. If the user does not select a value, I set e.cancel to true returning them to input a value.
If ((cboName.SelectedIndex = -1) And (cboName.Text <> "")) Then
If (MsgBox("'" & cboName.Text & "' was not found, Do you want to add it?", _
MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Not Found") = vbYes) Then
' Handle the add to database
Else
e.Cancel = True
End If
Else
If (cboName.SelectedIndex = 0) Then
e.Cancel = True
cboName.SelectedIndex = -1
End If
The problem I have now is I am unable to terminate the app until they enter something. What is the best way to validate the input selection but still be able to abort the form?
If ((cboName.SelectedIndex = -1) And (cboName.Text <> "")) Then
If (MsgBox("'" & cboName.Text & "' was not found, Do you want to add it?", _
MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Not Found") = vbYes) Then
' Handle the add to database
Else
e.Cancel = True
End If
Else
If (cboName.SelectedIndex = 0) Then
e.Cancel = True
cboName.SelectedIndex = -1
End If
The problem I have now is I am unable to terminate the app until they enter something. What is the best way to validate the input selection but still be able to abort the form?