New to class modules....not sure I really understand them properly.
What I'm trying to do is create a list of engineers, log the dates each has worked and produce a count of jobs per day to calculate an average with.
So....what I was thinking of was something like an array of Engineers(1 to 200) as string and two other variables, one being WorkDay(1 to 10000) date and JobDay(1 to 10000) as integer
However, a co-worker suggested using a class module instead:
cFranchise
Private cName As String
Private cWorkDay(1 To 10000) As Date
Private cJobDay(1 To 10000) As Integer
Public Property Get Name() As String
Name = cName
End Property
Public Property Let Name(Value As String)
cName = Value
End Property
Public Property Get WorkDay() As Date
WorkDay = cWorkDay
End Property
Public Property Let WorkDay(Value As Date)
cJobDay = Value
End Property
Public Property Get JobDay() As Integer
WorkDay = cWorkDay
End Property
Public Property Let JobDay(Value As Integer)
cJobDay = Value
End Property
Now, I've managed to get it to create multiple instances of the class:
Dim Engineers As Collection
Dim Engineer As cFranchise
Set Engineers = New Collection
For Sweep = 6 To 14
Set Engineer = New cFranchise
Engineers.Add Engineer
Engineer.Name = Cells(Sweep, 5).Value
Next Sweep
And I can read them back in sequential order:
For Each Engineer In Engineers
MsgBox Engineer.Name
Next Engineer
Now comes the complete bonehead question:
How do I reference an individual instance of the class in order to assign values to the other variables?
Like.....if code is scanning through a data set, finds the engineer name, searches the collection for a matching engineer name......how does it assign the date worked to WorkDay(n) of that particular instance?
Or am I barking up the wrong tree completely and this can be done easily with a multidimensional array (also new to me).
Google has only managed to get me this far....
Bookmarks