How can I change this function into an object ie class module so that I can return either the
DiaryDue value
vtDueDays value
vtDueHrs value
vtDueMins value
by typing soming like DiaryDue.vtdueDays or DiaryDue.vtdueMins etc
Please help...
The function is:
DiaryDue value
vtDueDays value
vtDueHrs value
vtDueMins value
by typing soming like DiaryDue.vtdueDays or DiaryDue.vtdueMins etc
Please help...
The function is:
Code:
Public Function DiaryDue(vtRemDateTime As Variant) As Variant
Dim vtRemDate As Variant
Dim vtRemTime As Variant
Dim vtDueDays As Variant
Dim vtDueHrs As Variant
Dim vtDueMins As Variant
Dim CurrentDate As Variant
Dim CurrentTime As Variant
CurrentDate = Date
CurrentTime = Time
vtRemDate = Format(vtRemDateTime, "DD/MM/YYYY")
vtRemTime = Format(vtRemDateTime, "HH:NN:SS")
vtDueDays = DateDiff("d", vtRemDate, CurrentDate)
vtDueHrs = Int(DateDiff("n", vtRemTime, CurrentTime) / 60)
vtDueMins = DateDiff("n", vtRemTime, CurrentTime) - Int(DateDiff("n", vtRemTime, CurrentTime) / 60) * 60
If vtDueDays > 0 Then
If vtDueDays > 1 Then
DiaryDue = vtDueDays & " days overdue"
Else
DiaryDue = 1 & " day overdue"
End If
ElseIf vtDueHrs > 0 Then
If vtDueHrs > 1 Then
DiaryDue = vtDueHrs & " hrs "
Else
DiaryDue = 1 & " hr "
End If
If vtDueMins > 0 Then
If vtDueMins > 1 Then
DiaryDue = DiaryDue & vtDueMins & " mins"
Else
DiaryDue = DiaryDue & 1 & " min"
End If
End If
DiaryDue = DiaryDue & " overdue"
Else
If vtDueHrs < 0 Then
vtDueHrs = Int(DateDiff("n", CurrentTime, vtRemTime) / 60)
If CurrentTime < vtRemTime Then
vtDueMins = DateDiff("n", CurrentTime, vtRemTime) - Int(DateDiff("n", CurrentTime, vtRemTime) / 60) * 60
End If
If vtDueHrs > 0 Then
If vtDueHrs > 1 Then
DiaryDue = vtDueHrs & " hrs "
Else
DiaryDue = 1 & " hr "
End If
End If
If vtDueMins > 0 Then
If vtDueMins > 1 Then
DiaryDue = DiaryDue & vtDueMins & " mins"
Else
DiaryDue = DiaryDue & 1 & " min"
End If
End If
'DiaryDue = "Due in " & DiaryDue
Else
If vtDueMins < 0 Then
If vtDueHrs < 0 Then
If vtDueHrs * (-1) = 1 Then
DiaryDue = vtDueHrs * (-1) & " hour"
Else
DiaryDue = vtDueHrs * (-1) & " hours"
End If
Else
DiaryDue = vtDueMins * (-1) & " minutes"
End If
ElseIf vtDueMins > 1 Then
DiaryDue = vtDueMins & " minutes overdue"
Else
DiaryDue = 1 & " minute overdue"
End If
End If
End If
'Int(DateDiff("n",[RemTime],Time())/60)
End Function