Inherits can appear only once within a 'Class' statement and can only specify one class

Ive been trying to follow the example from:-
http://www.vbdotnetheaven.com/uploadfile/dsandor/activexcontrolinvbdotnet04112005081747am/activexcontrolinvbdotnet.aspx

And Ive come up with the attached code, however when I try and use the line:-
         Inherits System.Windows.Forms.UserControl, AxMyControl
I get the error:-
         Inherits' can appear only once within a 'Class' statement and can only specify one class.

Any ideas? how I can tell it to inherit both so it works in IE?

Thank you

Namespace ActiveXDotNet
    Public Interface AxMyControl
        Property UserText As String
    End Interface
End Namespace

Public Class myControl
    Inherits System.Windows.Forms.UserControl, AxMyControl

    Private mStr_UserText As String
    Public Property userTest As String
        Get
            Return mStr_UserText
        End Get
        Set(ByVal value As String)
            mStr_UserText = value
            TextBox1.Text = mStr_UserText
        End Set
    End Property
End Class

Open in new window

tonelm54Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cascader_grCommented:
If AxMyControl is an Interface, the correct declaration is:


Public Class myControl
    Inherits System.Windows.Forms.UserControl
    Implements AxMyControl

Open in new window

0
tonelm54Author Commented:
That doesnt work, it doesnt seem to see AxMyControl.

The error message I get is:-
Type 'AxMyControl' is not defined.

Code Ive got so far is attached
Namespace ActiveXDotNet
    Public Interface AxMyControl
        Property UserText As String
    End Interface
End Namespace

Public Class myControl
    Inherits System.Windows.Forms.UserControl
    Implements AxMyControl
    
    Private mStr_UserText As String
    Public Property userTest As String
        Get
            Return mStr_UserText
        End Get
        Set(ByVal value As String)
            mStr_UserText = value
            TextBox1.Text = mStr_UserText
        End Set
    End Property
End Class

Open in new window

0
cascader_grCommented:
The code you reference contains the declaration of the interface:

Public Interface AxMyControl
Property UserText() As String
End Property
End Interface 'AxMyControl

Open in new window

0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

cascader_grCommented:
You have to move the "End Namespace" after your class definition so it contains both the interface and your class.

Please ignore previous comment...
0
Paul_Harris_FusionCommented:
I think the problem is the namespace
your interface is defined within the ActiveXDotNet namespace

Either remnove the following namespace lines from around your interface
  Namespace ActiveXDotNet
  End Namespace

OR

in your class, change
   Implements AxMyControl
to
  Implements ActiveXDotNet.AxMyControl


0
tonelm54Author Commented:
If I use the following code I get the message telling me that the textbox I have in my design is not declared:-
          Name 'TextBox1' is not declared.      
Namespace ActiveXDotNet
    Public Interface AxMyControl
        Property UserText As String
    End Interface

    Public Class myControl
        Inherits System.Windows.Forms.UserControl
        Implements ActiveXDotNet.AxMyControl

        Private mStr_UserText As String

        Public Property UserText As String Implements AxMyControl.UserText
            Get
                Return mStr_UserText
            End Get
            Set(ByVal value As String)
                mStr_UserText = value
                TextBox1.Text = mStr_UserText
            End Set
        End Property
    End Class
End Namespace

Open in new window

0
Paul_Harris_FusionCommented:
My guess is that your class is split across two partial classes which have mimatched namespaces.

I would try removing the definition and references to the ActiveXDotNet name space and get it working before you put the name spacing back in (if you need to).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.