I'm ready to pull my hair out with this!!! I'm trying to validate a textbox so that only a Integer or a Decimal can be entered. If I enter a 1 in the box it validates fine and the focus moves to the next control. If I enter 1.5 it validates but the focus is locked into textbox and I can't click or tab out of the box. I tried flipping the e.cancel value but that did not work.
Here's the code:
I was having simular issues trying to use the Decimal.TryPars e()
Here's the code:
Code:
Private Sub txtInterest_Validating(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtInterest.Validating
Try
Decimal.Parse(txtInterest.Text)
e.Cancel = False
Catch ex As Exception
MessageBox.Show("Please enter the interest amount in the form of a decimal.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
e.Cancel = True
End Try
End Sub
Comment