Object Oriented – OO – Visual Basic 6 Specifics – VB6

 
 
The word "Set" is often required. Omitting this in the following would compile but go through the Get routine instead and error in runtime.
 
Private Sub Class_Initialize()
    Set Me.Employee = New Employee
End Sub
 
 
In loops there are two options
Either Dim object as New instance inside loop. Then set to Nothing before next loop.
Do Until rsTD.EOF
Dim cTimeSheet As New clsTimeSheet
cTimeSheet.Employee.EmpeeNo = rsTD!EmpeeNo
Call cJS.colTimeSheets.AddTimeSheet(cTimeSheet, lngMaxEmp)

Set cTimeSheet = Nothing

rsTD.MoveNext
Loop

Or following with or without first New
Dim cTimeSheet As New clsTimeSheet

Do Until rsTD.EOF
Set cTimeSheet = New clsTimeSheet
cTimeSheet.Employee.EmpeeNo = rsTD!EmpeeNo
Call cJS.colTimeSheets.AddTimeSheet(cTimeSheet, lngMaxEmp)

rsTD.MoveNext
Loop

 
 
 
 
 
 
 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: