Question about Implements

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone,
I'm trying to implement the ISupportInitialize interface, in the object
browser there implemented like the followinfg:
Public Overridable Sub BeginInit()
Public Overridable Sub EndInit()

I get the following build errors for both functions.
'MyDialog' Must implement 'OVerridable Sub BeginInit()' for interface
'System.ComponentModel.IsupportInitialize'.

Here is the class that implements the interface. Why does it give me these
error since I have implemented those subs in my class. Thanks for any help.
Public Class MyDialog
Implements ISupportInitialize

Public Sub BeginInit()
End Sub

Public Sub EndInit()
Dim ret As DialogResult = Mfd.ShowDialog()
End Sub

Public Sub New()
ofd = New OpenFileDialog()
End Sub 'New
End Class
 
Michael said:
Here is the class that implements the interface. Why does it give me
these error since I have implemented those subs in my class.

You have created functions with names that match those in the interface, but
you haven't told VB that they actually implement the functions in the
interface.

Try this:

\\\
Public Sub BeginInit() Implements ISupportInitialize.BeginInit
[...]
End Sub

Public Sub EndInit() Implements ISupportInitialize.EndInit
[...]
End Sub
///

This tells VB that the functions provide the implementation for the
BeginInit and EndInit members of the interface.

Hope that helps,
 
Michael,

In your MyDialog class you need to implement the methods with the Implements
clause as ISupportInitialize.methodname, indicating that you are fulfilling
the contract with the interface

ex
Public Sub BeginInit() Implements ISupportInitialize.BeginInit

End Sub

Similarly for the EndInit method.

HTH

HTH
 
THanks so much for the reply you all.
Michael

Oenone said:
Michael said:
Here is the class that implements the interface. Why does it give me
these error since I have implemented those subs in my class.

You have created functions with names that match those in the interface, but
you haven't told VB that they actually implement the functions in the
interface.

Try this:

\\\
Public Sub BeginInit() Implements ISupportInitialize.BeginInit
[...]
End Sub

Public Sub EndInit() Implements ISupportInitialize.EndInit
[...]
End Sub
///

This tells VB that the functions provide the implementation for the
BeginInit and EndInit members of the interface.

Hope that helps,
 
Back
Top