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?
 
Paul_Harris_FusionConnect With a Mentor Commented:
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
 
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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
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
 
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
All Courses

From novice to tech pro — start learning today.