sneha Level: Scholar
 Registered: 28-03-2006 Posts: 29
|
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
|