Hi All,
Just a query really as i havent really written a class from scratch before so i am struggling getting my head round the log of it to be honest.
What: I am trying to extend a class with another class, so once the main class has been instantiated then they can then choose from a series of subclasses that they can they populate properties - the final peice will have approx 150 properties so i need to break up and catagorise some properties.
My issue here is that when i created a nested class, the user can directly instantiate the subclass which i do not want them to do, i want all the subclasses to be part of the main class and prevent direct instantiation of them.
This is what i want them to do:
Code:Dim IE1 As New IncomeExpenditure IE1.CustomerData.FullName = "HELLO"
I do not want them to be able to do this.
Here is my class code so far, can someone please help me code out the ability to directly instantiate the sub class becuase there will be subs/functions in the main class that accesses properties through the sub class so i do not want them accessing it as this class will be a widely used class in several applications (once built). I have read items on Inherit, Private Default Constructors etc but when i make the change it gives me errors about accessing private members on the classes etc or the 'CustomerData' becomes unavailable.Code:Dim IE2 As New IncomeExpenditure.CustomerInfo IE2.FullName = "Test"
Appreciate any help you guys can give.
Code:Public Class IncomeExpenditure Public CustomerData As CustomerInfo 'Private Private m_TimeStampID As String Private m_ActiveStatus As String Private m_SourceId As String Private EmployeeId As Integer Public Sub New() 'Private Constructor Debug.Print("Constructor") End Sub #Region "Customer Info Class" '############################################################## 'Class: clsHouseHoldInfo 'Values: Under 14 Dependent Children ' 14 - 16 Dependant Children (19 if in further ed) ' Non Dependent Household Members (Bill Contributers) '############################################################## Public Class CustomerInfo Private m_AC_ACCOUNT_NUMBER As Long Private m_AC_ACCOUNT_NAME As String Private m_AC_ACCOUNT_DOB As Date Private m_AC_ACCOUNT_EMAIL As Date Public Property DebtId() As Long Get Return m_AC_ACCOUNT_NUMBER End Get Set(value As Long) m_AC_ACCOUNT_NUMBER = value End Set End Property Public Property FullName() As String Get Return m_AC_ACCOUNT_NAME End Get Set(value As String) m_AC_ACCOUNT_NAME = value End Set End Property Public Property DateOfBirth() As Date Get Return m_AC_ACCOUNT_DOB End Get Set(value As Date) m_AC_ACCOUNT_DOB = value End Set End Property Public Property EmailAddress() As Date Get Return m_AC_ACCOUNT_DOB End Get Set(value As Date) m_AC_ACCOUNT_DOB = value End Set End Property End Class #End Region #Region "HouseHold Info Class" '############################################################## 'Class: clsHouseHoldInfo 'Values: Under 14 Dependent Children ' 14 - 16 Dependant Children (19 if in further ed) ' Non Dependent Household Members (Bill Contributers) '############################################################## Private Class clsHouseHoldInfo Private m_AC_DEPENDENT_CHILDREN_LT14 As Long Private m_AC_DEPENDENT_CHILDREN_14PL As Long Private m_AC_NO_IN_HOUSEHOLD As Long Private m_AC_VEHICLES_IN_HOUSEHOLD As Long Public Property Under14_Dependants() As Long Get Return m_AC_DEPENDENT_CHILDREN_LT14 End Get Set(value As Long) m_AC_DEPENDENT_CHILDREN_LT14 = value End Set End Property Public Property Over14_Dependants() As Long Get Return m_AC_DEPENDENT_CHILDREN_14PL End Get Set(value As Long) m_AC_DEPENDENT_CHILDREN_14PL = value End Set End Property Public Property NonDependants() As Long Get Return m_AC_NO_IN_HOUSEHOLD End Get Set(value As Long) m_AC_NO_IN_HOUSEHOLD = value End Set End Property Public Property NumberOfVehicles() As Long Get Return m_AC_VEHICLES_IN_HOUSEHOLD End Get Set(value As Long) m_AC_VEHICLES_IN_HOUSEHOLD = value End Set End Property End Class #End Region End Class




Reply With Quote