First off, don;t use Val in VB, or Convert in C# to convert user input - particularly date based.
Instead use the various TryParse / TryParseExact methods and report errors to the user instead of continuing. Better still, use a calendar control for data input instead of a textbox, so the user can't enter an invalid date and access the DateTime value directly.
DateTime dt;
if (!DateTime.TryParse(myTextBox.Text, out dt))
{
... report problem to user ...
return;
}
Do the same thing for your Installments using int.TryParse, and then it's trivial:
DateTime dueDate = dt.AddMonths(installments);
When you subtract two dates, you get a TimeSpan - you can't convert that to a date at all because it's just a "Number of ticks" between two points - it's like measuring two random points on a plane and subtracting them:
X = (2, 4), Y = (16, 3)
- you get the distance between them as
D = 14.03567
but that doesn't relate to the X or Y axes! Unless you pick a third point Z to base your "distance from" on, you can't draw it - and even then, you have an infinites number of points on a circle to chose from because distance doesn;t include any direction info!
Same this with
DateA - DateB
: you get a "number of days, hours, minutes" between them, but it's meaningless without a "new start point".