Cancel = True End If End Sub Private Sub Combobox1_Leave(sender As Object, e As System.
If the e-mail address is not in the standard format (containing "@" and "."), the validation fails, an Error Provider icon is displayed, and the event is canceled.This example requires that a Text Box and Error Provider control have been created on a form.When nothing is selected the Selected Item will return NULL, another option is using Selected Index which will return -1 when no item has been selected.So with the Selected Index it would become something like; Generally using string comparisons should only be done when anything "strong" like an int comparison or even better an enum comparison is not possible.For example, if you retrieve the Selected Text value in a button Click event handler, the value will be an empty string.
This is because the selection is automatically cleared when the input focus moves from the combo box to the button.Find the "validators" section and add a "validate required" entry and enter your message. Doing so can cause your application or the operating system to stop responding.I have decided to add some validation to my combobox, what I'm trying to achieve is to make sure that the user can ONLY enter fields that are in the combobox but the problem I have now is that if the user clicks on the combobox and doesnt enter anything and tries to leave the combobox the message box appears. Private Sub Combobox1_Validating(sender As Object, e As System. Which makes validation pretty useless (there's something selected). In the source, this is what it will look like: After that will be the rest of your entries - either hard-coded, or from a formula, or both.