English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Ex:
Date resigned 26.07.2006
Date Joined 30.10.1995
No of Years DD M YY

Please show how to get the answer in excel with vb source code

2006-07-26 07:48:13 · 3 answers · asked by maxy 1 in Computers & Internet Programming & Design

3 answers

There is a method within Visual Basic that will subtract dates for you which is, DateDiff.

The documentation of DateDiff is located here: http://msdn2.microsoft.com/en-us/library/b5xbyt6f.aspx

I don't know what method your using this. But you just get the date field (if it is date formated ) from the excel sheet as normal s you have done before. And you store that date field as a variable within Visual Basic. You do the same to the second date you wish to substract from. And you apply the DateDiff( ... );

' The following statements set datTim1 to a Thursday
' and datTim2 to the following Tuesday.
Dim datTim1 As Date = #1/4/2001#
Dim datTim2 As Date = #1/9/2001#
' Assume Sunday is specified as first day of the week.
Dim wD As Long = DateDiff(DateInterval.Weekday, datTim1, datTim2)
Dim wY As Long = DateDiff(DateInterval.WeekOfYear, datTim1, datTim2)


Good Luck

2006-07-26 11:15:16 · answer #1 · answered by ? 6 · 0 0

Why using VB when you can use Excel to do that:
Just substract date fro another like =A1-A2 (Where A1 has the end date, A2 has the start date) and then change the format of that cell into number, and you got the number of days in between.

If you still need to use VB, you do the same, Date1-Date2
because dates in Vb are numbers

good luck

Read my profile, I am XLMan

2006-07-29 00:28:58 · answer #2 · answered by Anonymous · 0 0

If you are 9 out of ten, many matters would be made. I needed to make a recreation too while I did VB in institution. A maze is consistently a well one, or a unfashionable online game, like tetris or house invaders. A card recreation might be too. If you are well sufficient, check out a platformer, like mario.

2016-08-28 17:32:55 · answer #3 · answered by ? 4 · 0 0

fedest.com, questions and answers