Question about Implements

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
 
O

Oenone

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,
 
G

Guest

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
 
G

Guest

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top