borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (Change Row Source Query on the fly)Next Topic (Tough task for me...) New Topic New Poll Post Reply
AndreaVB Forum : Database : To calculate the days from the date of Invoice issued?
Poster Message
sneha
Level: Scholar

Registered: 28-03-2006
Posts: 29

icon To calculate the days from the date of Invoice issued?

Hi,

I got an excellent code which is fantastic.
visual basic code:--------------------------------------------------------------------------------Public Sub DateAdd()
    
    Dim DueDate As Date
    Dim CP As Long
    Dim ID As Date
    
    CP = txtCreditPeriod.Text

    'the following assumes the string in the textbox converts to a date properly
    'it may not work correctly on computers whose date format
    'ie txtInvoiceDate.Text = 01/02/2006
    'if the Regional Setting is mm/dd/yyyy that will convert to Jan 2
    'if it is dd/mm/yyyy that will convert to Feb 1
    
    ID = txtInvoiceDate.Text

    'Since you named the procedure DateAdd, there is a conflict with VB's DateAdd function.
    'you need to ensure VB knows which DateAdd procedure to call
    'yours or the VBA function
    
    DueDate = VBA.DateAdd("d", CP, ID)

   txtDueDate.Text = Format$(DueDate, "dd-MM-yyyy")

End Sub--------------------------------------------------------------------------------

Now, besides this code I need to add one more textbox (txtTotalDays) which can display how many days are now (it should be updated whenever it starts the program) since the invoice issued.

Thanks in advance for the help.

Sneha

For example: Invoice No. 155 is issued on 01/05/2006 (dd/mm/yyyy) and today is 09/05/2006 ... so the textbox (txtTotalDays) should automatically show 9 (9 days in the txtTotalDays). How it can be done.

[Edited by sneha on 09-05-2006 at 06:24 PM GMT]

____________________________
Sneha

09-05-2006 at 10:20 AM
View Profile Send Email to User Show All Posts | Quote Reply
steve_w
Level: Moderator


Registered: 18-04-2003
Posts: 1156
icon Re: To calculate the days from the date of Invoice issued?

Hi

Have a look at the DateDiff function


Steve  

09-05-2006 at 11:08 AM
View Profile Send Email to User Show All Posts | Quote Reply
sneha
Level: Scholar

Registered: 28-03-2006
Posts: 29
icon Re: To calculate the days from the date of Invoice issued?

quote:
steve_w wrote:
Hi

Have a look at the DateDiff function


Steve  


Could you please give me clear example to understand DateDiff function?

Sneha.

____________________________
Sneha
09-05-2006 at 12:40 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1616
icon Re: To calculate the days from the date of Invoice issued?

It's the same basic format as the DateAdd() function, just with two dates instead of a date and a number.


____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)

09-05-2006 at 11:46 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : Database : To calculate the days from the date of Invoice issued?
Previous Topic (Change Row Source Query on the fly)Next Topic (Tough task for me...) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder