News:

Build a stunning handcrafted website with IT Acumens

Main Menu

Make a collection class

Started by nandagopal, Sep 15, 2008, 02:30 PM

Previous topic - Next topic

nandagopal

Make a class named clsEmployees to hold information about an employee. Then make an Employees class that holds clsEmployees objects. Give that class methods for adding, listing, and removing clsEmployee objects. For example, the following code creates a new clsEmployee object, adds it to the Employees object's collEmployees collection, and returns a reference to the new object. See the code for other routines.


Public Function Add(ByVal EmpNo As Long, ByVal EmpName As _
    String, ByVal EmpSalary As Double) As clsEmployee
Dim objEmployee As New clsEmployee

    objEmployee.EmployeeNo = EmpNo
    objEmployee.EmployeeName = EmpName
    objEmployee.EmployeeSalary = EmpSalary
 
    collEmployees.Add objEmployee, CStr(EmpNo)
 
    Set Add = objEmployee
End Function