I have a VBA function that basically goes along these lines:
Public Function JoinDateTime(DateTime As String, Time As String) As Date Dim dtDate As Date dtDate = CDate(Format(DateTime, "dd/mm/yyyy")) dtDate = dtDate & " " & Format(Time, "hh:mm") JoinDateTime = dtDate End Function
It binds the date and time together into a datetime value. (The real function has some more logic.)
The problem is that I would like to add processing for the annoying values passed to it. This is mainly for null / null values - if DateTime is empty, return empty. If this is a text string that returns #Error, so it doesn't just fail, it seems like a good idea.
The problem is that I'm not sure how to do this. I was thinking about making an early return, perhaps something like this at the beginning of the function:
If DateTime = Null or DateTime = "" Then JoinDateTime = Null End If
but he does not seem to consider this a return and still does the rest of the function.
Is there any way to do this? Is it better, ideally?
Margaret
source share