The way that the code is written now, FirstDate and LastDate are 12:00? When I make FirstDate and LastDate As Strings, they are just empty (""). I am trying to find the very first date in the Project and the very last date in the Project. I really just need help with getting the FirstDate to equal BeginDate and LastDate to equal EndDate.
Dim BeginDate As String
Dim EndDate As String
Dim FirstDate As Date
Dim LastDate As Date
'Inputs the Start Date of the Warranty
ActiveProject.Tasks(j).Start = BeginDate
'Pulls the End Date of the Warranty
Pos4 = InStr(Pos3 + 1, linetext, Separator)
EndDate = Trim(Mid(linetext, Pos3 + 1, Pos4 - (Pos3 + 1)))
'Inputs the End Date of the Warranty
ActiveProject.Tasks(j).Finish = EndDate
'Finds the Beginning and Ending of all warranties
If j = 2 Then
FirstDate = ActiveProject.Tasks(j).Start
LastDate = ActiveProject.Tasks(j).Finish
Else
FirstDate = WarrantyStart(BeginDate, FirstDate)
LastDate = WarrantyEnd(EndDate, FirstDate)
End If
Functions:
Function WarrantyStart(BeginDate, FirstDate)
If BeginDate < FirstDate Then
FirstDate = BeginDate
End If
End Function
Function WarrantyEnd(EndDate, FirstDate)
If EndDate > LastDate Then
LastDate = EndDate
End If
End Function
Dim BeginDate As String
Dim EndDate As String
Dim FirstDate As Date
Dim LastDate As Date
'Inputs the Start Date of the Warranty
ActiveProject.Tasks(j).Start = BeginDate
'Pulls the End Date of the Warranty
Pos4 = InStr(Pos3 + 1, linetext, Separator)
EndDate = Trim(Mid(linetext, Pos3 + 1, Pos4 - (Pos3 + 1)))
'Inputs the End Date of the Warranty
ActiveProject.Tasks(j).Finish = EndDate
'Finds the Beginning and Ending of all warranties
If j = 2 Then
FirstDate = ActiveProject.Tasks(j).Start
LastDate = ActiveProject.Tasks(j).Finish
Else
FirstDate = WarrantyStart(BeginDate, FirstDate)
LastDate = WarrantyEnd(EndDate, FirstDate)
End If
Functions:
Function WarrantyStart(BeginDate, FirstDate)
If BeginDate < FirstDate Then
FirstDate = BeginDate
End If
End Function
Function WarrantyEnd(EndDate, FirstDate)
If EndDate > LastDate Then
LastDate = EndDate
End If
End Function