Reputation: 5174
I'm trying to build a class module with my whole Company as follows:
Now I know how to achieve this thanks to this answer.
The thing is I am on a planning area which will schedule everyone's work and shifts, so I need to add both Dates and timetable... I want to build a timetable for the whole day dividied by every single minute, so 1440 minutes.
If I were to write the 2 classes with the properties I need such as Auxiliar Time and Workers on the shift, could I call them from any other class without messing with each other?
My goal is to be able to for example sum the Aux time given a day, a group of minutes depending on the department, or the department in a specific location.
I understand this is going to be tedious to write, but is it possible to achieve such a thing?
My code right now calls the Agent which will have different properties, such as his location, service, name and area. By giving his ID you can fill these and if you feed the class a Date, you can get his schedule, department and a comment.
I understand this would have to change, all of it, but I just need to know if is possible what I'm trying to accomplish here, or is there any way more efficient than my initial structure.
My code goes as follows:
Company Class:
Option Explicit
Private ID As Object
Property Get clAgente(ByVal Key As String) As clAgente
With ID
If Not .Exists(Key) Then .Add Key, New clAgente
End With
Set clAgente = ID(Key)
End Property
Public Property Get Count() As Long
Count = ID.Count
End Property
Public Property Get Keys() As Variant
Keys = ID.Keys
End Property
Private Sub Class_Initialize()
Set ID = CreateObject("Scripting.Dictionary")
End Sub
Private Sub Class_Terminate()
Set ID = Nothing
End Sub
Agent Class:
Option Explicit
Private Centro As String
Private Servicio As String
Private Nombre As String
Private DirNeg As String
Private Agrup As String
Private Fechas As Object
Property Get Business() As String
Business = DirNeg
End Property
Property Let Business(ByVal param As String)
DirNeg = param
End Property
Property Get Group() As String
Group = Agrup
End Property
Property Let Group(ByVal param As String)
Agrup = param
End Property
Property Get Location() As String
Location = Centro
End Property
Property Let Location(ByVal param As String)
Centro = param
End Property
Property Get Service() As String
Service = Servicio
End Property
Property Let Service(ByVal param As String)
Servicio = param
End Property
Property Get Name() As String
Name = Nombre
End Property
Property Let Name(ByVal param As String)
Nombre = param
End Property
Property Get clHorarios(ByVal Key As Date) As clHorarios
With Fechas
If Not .Exists(Key) Then .Add Key, New clHorarios
End With
Set clHorarios = Fechas(Key)
End Property
Private Sub Class_Initialize()
Set Fechas = CreateObject("Scripting.Dictionary")
End Sub
Private Sub Class_Terminate()
Set Fechas = Nothing
End Sub
Public Property Get Count() As Long
Count = Fechas.Count
End Property
Public Property Get Keys() As Variant
Keys = Fechas.Keys
End Property
And finally,
Date class:
Option Explicit
Private m_Horario As String
Private m_Modo As String
Private m_Coment As String
'Aquí creamos la propiedad Horario para la clase Fecha
Public Property Get Horario() As String
Horario = m_Horario
End Property
Public Property Let Horario(ByVal param As String)
m_Horario = param
End Property
'Aquí creamos la propiedad Modo para la clase Fecha
Public Property Get Modo() As String
Modo = m_Modo
End Property
Public Property Let Modo(ByVal param As String)
m_Modo = param
End Property
'Aquí creamos la propiedad Coment para la clase Fecha
Public Property Get Comentario() As String
Comentario = m_Coment
End Property
Public Property Let Comentario(ByVal param As String)
m_Coment = param
End Property
Any insight on the matter would be greatly appreciated.
Upvotes: 1
Views: 149
Reputation: 1485
[...] could I call them from any other class without messing with each other?
Keep in mind that the class is just the structure and meaningless until instantiated and assigned to an object variable that can be copied and modified by any line of code within scope. So, whether or not any class has access to that variable is dependent on scope and whether or not you end up with a mess depends on you and our design.
[...] is it possible to achieve such a thing?
If you did not already know that it is possible to do this thing, then you will have a significant amount of learning to do before you can do this thing.
Any insight on the matter would be greatly appreciated.
Nothing you haven't heard before and you're not already doing: read, try, and learn.
Upvotes: 1