Forms inheritance in VB 2010

Discussion in 'Visual Basic .Net' started by DN Admin, Dec 31, 2012.

  1. DN Admin

    Staff Member

    Joined:
    Aug 7, 2010
    Location:
    Joliet, IL U.S.A.
    <pre class="prettyprint lang-vb I have a form that has my base class that I would like a. create a child with two variables (one is string and the other is an array. I am getting an error stating that " 'Class Main.StimExam2' must declare a 'Sub New' because its base class 'Main.MyMainFormClass' doesn't have an accessible 'Sub New' I appreciate any hint, <span style="font-size:15.5pt; line-height:115%; font-family:'Courier New'; color:#2B91AF </span> ‘Child form
    Public Class StimExam2
    Inherits MyMainFormClass
    Dim answerarray As String() = {"B", "C", "B", "D", "D", "B", "D", "A", "D", "B"}
    Dim StimExam2 As New MyMainFormClass ("P", answerarray)

    End Class
    '------ end of the child form---------------


    ‘ in main form class = MyMainFormClass, I added the following to initiate the two variables

    Private examFirstLetter As String ' first letter of the exam files
    Private QA As String() ' array of questions anawers

    Public Sub New(ByVal name As String, ByVal answerarray As String())
    myletter = name ' initiate the first letter
    QA = answerarray

    End Sub 'NEW


    Public Property myletter() As String
    Get
    Return examFirstLetter

    End Get
    Set(ByVal value As String)
    examFirstLetter = Name
    </pre>
    <br/>

    View the full article
     
    #1

Share This Page