Link to home
Start Free TrialLog in
Avatar of brokeMyLegBiking
brokeMyLegBiking

asked on

Can I use an Interface instead of Late Binding?

1)I have two child forms which both have a method with the same name and signature:
    Public Sub initialize_validation()
        For Each control As Control In util.get_controlTagCol(Me)
            controlValidation.Control_Validating(control, Me.DefInstance, ErrorProvider1, Me.DefInstance.btnAddDisabled, False)
        Next
    End Sub

2)I would like to call this method from a third, parent form based on a reference passed for one of the two child forms.

3)for example:

if somethingTrue then
  frm = childFormOne
else
  frm = childFormTwo
end if
frm.initialize_validation()

4) I can accomplish this with late binding, if I turn off Option Strict. However, I would prefer not to have to use late binding. Does anyone know a better way? Perhaps with an Interface? (I have not used interefaces before, I have only read about them, and don't quite understand how to use them and if they will solve my issue here)
SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brokeMyLegBiking
brokeMyLegBiking

ASKER

Well I knew that C# programmers would be smarter regarting Interface than VB.NET coders :).  You can answer in C#, or VB.NET either way I can understand.

Can a class which impliments an Interface have more methods than are defined in the Interface?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it worked, it's alive! (evil laugh)

awesome, I've been wondering how to do that for a while. So long ugly case statements and late binding!

thx for your help and the sample. kudos!