Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleMake a collection class
Keywordscollection class
CategoriesSoftware Engineering
 
By Vijay Sharma.

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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated