|
-
September 21st, 1999, 04:41 PM
#1
A Collection of user define type
How to write a user define type of Collection? The following code won't work.
Type EmployeeRecord
ID As Integer
Name As String
Address As String
End Type
Sub CreateRecord()
Dim MyRecord As EmployeeRecord
Dim MyCollection As Collection
MyRecord.ID = 12003 ' Assign a value to an element.
Set MyCollection = new Collection
MyCollection.Add(MyRecord)
End Sub
-
September 22nd, 1999, 12:37 AM
#2
Re: A Collection of user define type
Collections Work only on objects. So turn your employee type into a class and it will work.
Some thing like this:
Add a Class, and name it CEmployeeRecord
in it put these members. Make them all Public
public ID as Integer
public Name as string
public Address as string
and biuld your collection like this:
Sub CreateRecord()
Dim MyRecord as CEmployeeRecord
Dim MyCollection as Collection
set MyRecord = new CEmployeeRecord
MyRecord.ID = 12003 ' Assign a value to an element.
set MyCollection = new Collection
MyCollection.Add(MyRecord)
set MyRecord = nothing
End Sub
RK
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|