loyal Posted August 7, 2003 Posted August 7, 2003 how to invoke the e argument in Validating Sub ? well I have a text box that used ErrorProvider in Validating Event I want to cancel the validating by invoke the sub and send false to the( e ) argument But how ? Here is the code If IsNumeric(txtName.Text) Then ErrorProvider1.SetError(txtName, "Please Enter a string Value") e.Cancel = True Else ErrorProvider1.SetError(txtName, "") End If :cool: Quote Gary Says: To be a good programmer, you must be good at debugging
*Experts* Volte Posted August 7, 2003 *Experts* Posted August 7, 2003 What do you mean "invoke the e argument"? Quote
loyal Posted August 7, 2003 Author Posted August 7, 2003 hi well see this pic please Quote Gary Says: To be a good programmer, you must be good at debugging
*Experts* mutant Posted August 7, 2003 *Experts* Posted August 7, 2003 If im understanding correctly what you want to do cant be done. You cant pass in a boolean value in place of System.ComponentModel.CancelEventArgs, and you cant change the value like that because you are setting it to true anyway. You could make another boolean value that will be for example set to true and if its true then change e.Cancel to false. All of this is based on assumption :). Quote
*Experts* Volte Posted August 7, 2003 *Experts* Posted August 7, 2003 Actually, what you need to do is create a CancelEventArgs, not a boolean, and pass that in. Dim args As New System.ComponentModel.CancelEventArgs() args.Cancel = False txtName_Validating(Nothing, args) Quote
loyal Posted August 7, 2003 Author Posted August 7, 2003 that's it >>>>>>> yeah I love this Forum Quote Gary Says: To be a good programmer, you must be good at debugging
loyal Posted August 7, 2003 Author Posted August 7, 2003 (edited) the first work perfectly but the second I don't know why here's the applcation see if there's a mistake I have done here's the code Dim b As Boolean Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load b = True End Sub Private Sub txtName_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtName.Validating Dim ico As New Icon(Application.StartupPath & _ "\MSGBOX01.ico") ErrorProvider1.Icon = ico 'If the Vaue is Number Then If IsNumeric(txtName.Text) Then ErrorProvider1.SetError(txtName, "Please Enter a string Value") e.Cancel = True Else ErrorProvider1.SetError(txtName, "") End If End Sub Private Sub txtpassword_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtpassword.Validating If Not IsNumeric(txtpassword.Text) Then Dim ico As New Icon(Application.StartupPath & _ "\FACE04.ico") ErrorProvider1.Icon = ico ErrorProvider1.SetError(txtpassword, "Please Enter a Numeric Value") e.Cancel = b Else ErrorProvider1.SetError(txtpassword, "") End If End Sub ' This works perfectly '////////////////////////// Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click b = False Me.Close() End Sub 'This I have no Idea 'it doesn't work ? '////////////////////////// Private Sub btnInvoke_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInvoke.Click 'TODO: I Don't Know why it does not work ? Dim myCancel As New System.ComponentModel.CancelEventArgs() myCancel.Cancel = False txtName_Validating(Nothing, myCancel) Me.Close() End Sub errorprovider.zip Edited November 28, 2005 by PlausiblyDamp Quote Gary Says: To be a good programmer, you must be good at debugging
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.