Visual Basic 6 Date Comparison by Month
April 5, 2006 6:31 PM   RSS feed for this thread Subscribe

Last Minute Visual Basic 6 Help!!! How do I compare a given date to today's date, based on a number of months?

I'm writing a tuition and billing program for my former high school, which is due tomorrow. The only part that's really making me unsure of my abilities is the part that generates bills. I've got it set up so the user can generate by date, student, and tuition plan. It's the date part that is throwing me for a loop.

What I'm looking for is some way to compare a date like so:
If Date = FirstPaymentDueDate + (one month) Then (do stuff)
If Date = FirstPaymentDueDate + (two months) Then (do stuff)
etc.
(where FirstPaymentDueDate is a pre-existing variable of type Date)

Is there some easy way to do this (that is, fill in the code for "one month" and "two months")? Or do I have to use some sort of brutal string manipulation?

Thanks!
posted by fvox13 to computers & internet (4 comments total)
Can you just extract the Day, Month, and Year out of both dates, and do something like:

If Date(Day(Now()), Month(Now()), Year(Now())) = Date(Day(Now()), Month(Now()) + 1, Year(Now())) Then

It might be DateSerial(,,,) that I'm thinking about. You'll also have to do some hoop-jumping for the year-end stuff.
posted by odinsdream at 6:38 PM on April 5, 2006


You probably want the DateAdd function.

Doesn't anyone read the docs anymore?
posted by sbutler at 6:59 PM on April 5, 2006


Thanks guys (girls?). I'm still relatively new at VB, so pretty much everything I do starts with a lot of google searches. When those fail, I turn to expert assistance!
posted by fvox13 at 7:23 PM on April 5, 2006


If you're getting into VB6, a good reference for the built-in functions is the O'Reilly book VB and VBA in a Nutshell. Much better than the help files, in my opinion.
posted by SteveInMaine at 5:55 AM on April 6, 2006


« Older What's the best way for me to ...   |   What reasonable, legal reason ... Newer »
This thread is closed to new comments.