I'm having a problem that I cant figure out, I'm trying to code a payroll system with vb.net 2013, I must use a console application.
I'm using classes to calculate the salary depending on the amount of weeks that the employee's worked, but the problem is that I cannot inherit from my parent class, I keep on getting this error and i don't know how to fix it.
Error 2 Class 'Employee_Payment_System.Employee' has no accessible 'Sub New' and cannot be inherited. Whenever i try to add a 'sub new' I get this
Error 3 'Public Sub New()' has multiple definitions with identical signatures. Here is my code so far
Public Class Employee #Region "Private Declarations" Private EMP_FullName As String Private EMP_LastName As String Private EMP_Salary As Double Private EMP_Number As Integer Private EMP_Address As String #End Region 'The values are obtained from the public properties coded below Private Sub New() EMP_FullName = "" EMP_LastName = "" EMP_Salary = 0.0 EMP_Address = "" End Sub Private Sub New(ByVal FullName As String, ByVal LastName As String, ByVal Address As String, ByVal Salary As Double, ByVal Number As Integer) EMP_FullName = FullName EMP_LastName = LastName EMP_Address = Address EMP_Number = Number EMP_Salary = Salary End Sub ' the properties gets their values from the console Public Property FullName() As String Get Return EMP_FullName End Get Set(value As String) EMP_FullName = value End Set End Property Public Property LastName() As String Get Return EMP_LastName End Get Set(value As String) EMP_LastName = value End Set End Property Public Property Address() As String Get Return EMP_Address End Get Set(value As String) EMP_Address = value End Set End Property Public Property Salary() As Double Get Return EMP_Salary End Get Set(value As Double) EMP_Salary = value End Set End Property Public Property Number() As Integer Get Return EMP_Number End Get Set(value As Integer) EMP_Number = value End Set End Property Public Overridable Function Payment() As Double Return EMP_Salary End Function End Class Public Class WeeklySalary : Inherits Employee 'The main problem "Error 2 Class 'Employee_Payment_System.Employee' has no accessible 'Sub New' and cannot be inherited." generates here Sub New()' I get my second error "Error 3 'Public Sub New()' has multiple definitions with identical signatures. " here End Sub Private NumberOfWeeks As Integer Private Sub New() 'The second Error is related to this sub NumberOfWeeks = 0 End Sub Public Sub New() NumberOfWeeks = Number End Sub Public Property Number_Of_Weeks() As Integer 'This is the number of weeks worked Get Return NumberOfWeeks End Get Set(value As Integer) NumberOfWeeks = value End Set End Property Public Overrides Function Payment() As Double Return NumberOfWeeks * Salary 'Calculates Weekly salary here End Function End Class I still have to code one more Class for monthly payments, and I still need to code the module for the console interface but I need my classes to work before I can start the module (For testing purposes).
Newprivate?