Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Date calculator


Reply
 
Thread Tools Display Modes
  #1  
Old 03-10-2006, 08:50 AM
Lars213 Lars213 is offline
Regular
 
Join Date: May 2004
Location: Ohio
Posts: 89
Default Date calculator


Hello,

I am trying to write a simple VB program in VB6 that displays the payoff date of a loan based on the number of payments that it will take.

Right now, I have the user input the balance owed on the loan, the payment amount that will be made each pay period (this payment amount will be the same amount for each payment on the life of the loan - ex. $25 per pay for the life of the loan), the payment frequency (either weekly, bi-weekly, or monthly), and the starting date.

I had no problems calculating the weekly and bi-weekly dates, but I do not know how to do the monthly date, since there are different days in each month. For my weekly and bi-weekly, I'm using the following code:

If cmbPaymentFrequency = "Weekly" Then
txtPayoffDate = temp + ((numPayments - 1) * 7)
ElseIf cmbPaymentFrequency = "Bi-Weekly" Then
txtPayoffDate = temp + ((numPayments - 1) * 14)

The variable 'temp' is defined as: temp = CDate(txtStartingDate) So it is storing the date entered in by the user in a date data type instead of a string data type.

Obviously I can not use the same format for the monthly payoff since there are different days in each month. Is there a way that if my program has a starting date of 3/15/2006 and it will take 4 payments to pay off the loan, that the payoff date will display 6/15/2006? The payment day for monthly payments would be the same day of every month.

Thanks in advance for any help that anyone can provide. I appreciate it!
Reply With Quote
  #2  
Old 03-10-2006, 09:15 AM
passel's Avatar
passel passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 7,714
Default

Code:
Option Explicit Private Sub Command1_Click() Dim d As Date d = "3/15/2006" d = DateAdd("m", 3, d) 'add 3 months to the date Debug.Print d End Sub
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #3  
Old 03-10-2006, 10:56 AM
Lars213 Lars213 is offline
Regular
 
Join Date: May 2004
Location: Ohio
Posts: 89
Default

Thank you very much for your help, that worked. Thanks again, I appreciate it!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->