I haven't worked much with classes, so I think this is a beginner's question.
I have a class that has the following property:
Private pAvtalsslut As Date
''''''''''''''''''''''
' Avtalsslut property
''''''''''''''''''''''
Public Property Get Avtalsslut() As Date
Avtalsslut = pAvtalsslut
End Property
Public Property Let Avtalsslut(Value As Date)
pAvtalsslut = Value
End Property
When I set property values to objects of this class I use the following validation in my subs:
If IsDate(exportWks.Cells(r, lColumnAvtalsslut)) Then
avtal.Avtalsslut = exportWks.Cells(r, lColumnAvtalsslut)
End If
I do this because otherwise I would get an error when the cell I read from is empty.
When I get property values from objects of this class I use the following validation in my subs:
If avtal.Avtalsslut <> 0 Then
wUnderlag.Cells(row, 3) = avtal.Avtalsslut
End If
I do this because I don't want to write zeros where there are no dates. I want to leave cells blank in that case.
Now to my question. What are some best practices for these kinds of validations? Should I have themin my class or in my subs? If they should be in my class, how should that look?
(PS.Is validation the correct vocabulary for these kinds of checks?)