calling an event in code.

  • Thread starter Thread starter JDMils
  • Start date Start date
J

JDMils

I have the following declaration:

Private Sub CheckForInvalidData(ByVal Sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles _

tbTotalTests.Validating, _

tbSellPrice.Validating, _

tbOtherCharges.Validating, _

tbNumTesters.Validating, _

tbTestsPerDay.Validating, _

tbLabourRate.Validating, _

tbConsCost.Validating

I want to call this procedure from my code. Here's what I have so far:

Private Function ValidateAllFields()
For Each xControl As Control In Me.Controls
If xControl.GetType Is GetType(TextBox) Then
If xControl.Tag = "I" Then
Call CheckForInvalidData(xControl, "")
....

But I get an error on the "" in the CALL statement saying "Error 1 Value of
type 'String' cannot be converted to
'System.ComponentModel.CancelEventArgs'. " So how do I call it?

VB.Net 2005
 
The second argument needs to be a CancelEventArgs type, not a string -
this is why it's popping the error.

So:

Call CheckForInvalidData(xControl, "")

Should be replaced by:

CheckForInvalidData(xControl, new
System.ComponentModel.CancelEventArgs())

Also, you do know you can just a Me.ValidateChildren() to force a
validation of all child controls right?

Thanks,

Seth Rowe
 
Back
Top