Better make it
Dim var_d1 AS Date, var_d2 AS Date

Without "As" it is not a valid Dim statement. The comparison is correct, though.