I see there are multiple "validation" type events to choose from in the "Declarations" drop-down box. I want to understand these choices better to see if one would work for what I want to do.
I've got several textboxes that need to have either a number entered into them or simply left blank. So I'd like to check during the time the user is inputing to see if what they have entered is correct, and if it's not, send them a message that they need to correct it. As an example:
If IsNumeric(txbSpecialPrice.Text) = False Or txbSpecialPrice.Text = "0" Then MessageBox.Show("This field must be blank or a valid special price greater than 0...", "Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) txbSpecialPrice.Focus()
So this prompted me to wonder if the event of "Validating" or something like it would be the best thing to use:
Private Sub txbCustNoType_Validating(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles txbCustNoType.Validating
If not this, what would the better to check during the run-time? I recognize that the user may not always tab or enter through each field, he/she may opt to use the mouse and go directly a specific box they want to choose. Therefore I think it would be wise to ensure each textbox has the correct kind of information in it.
What are your thoughts on this? Remember, I'm a newbie programmer. If you comment, please explain!
Thanks for your help.