Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[SOLVED]Days360 in vb6[SOLVED]

Hi,

Currently I am working on some application. Previously my tool was made in Excel with VBA. Excel is using the days360 code, which I (still) can't use/find in vb6.

I am looking for the right (excel) 'days360' code, which works in my vb6 project on textbox1.text and textbox2.text (which are date values).

Hopefully someone could help me.

Best regards,
iSmile.
If the function uses the parameters startdate and enddate, I found following code from vbcity.com

Code
Public Function Days360(StartDate As Date, EndDate As Date, Optional Method As Boolean = False) As Long
  Dim TempMonths As Long
  Dim StartDay As Long
  Dim EndDay As Long
  StartDay = Day(StartDate)
  EndDay = Day(EndDate)
  If Not Method Then
    If StartDay > 30 Then
      StartDate = DateAdd("d", -1, StartDate)
    End If
    If EndDay = 31 And StartDay > 30 Then
      EndDate = DateAdd("d", 1, EndDate)
    Else
      If EndDay = 31 Then
      EndDate = DateAdd("d", -1, EndDate)
      End If
    End If
  Else
    If StartDay > 30 Then
      StartDate = DateAdd("d", -1, StartDate)
    End If
    If EndDay > 30 Then
      EndDate = DateAdd("d", -1, EndDate)
    End If
  End If
  StartDay = Day(StartDate)
  EndDay = Day(EndDate)
  TempMonths = DateDiff("M", StartDate, EndDate)
  Days360 = (TempMonths * 30) + (EndDay - StartDay)
End Function
(Mar 27, 2015 11:02 AM)Danny233223_temp Wrote:  If the function uses the parameters startdate and enddate, I found following code from vbcity.com

Code
Public Function Days360(StartDate As Date, EndDate As Date, Optional Method As Boolean = False) As Long
  Dim TempMonths As Long
  Dim StartDay As Long
  Dim EndDay As Long
  StartDay = Day(StartDate)
  EndDay = Day(EndDate)
  If Not Method Then
    If StartDay > 30 Then
      StartDate = DateAdd("d", -1, StartDate)
    End If
    If EndDay = 31 And StartDay > 30 Then
      EndDate = DateAdd("d", 1, EndDate)
    Else
      If EndDay = 31 Then
      EndDate = DateAdd("d", -1, EndDate)
      End If
    End If
  Else
    If StartDay > 30 Then
      StartDate = DateAdd("d", -1, StartDate)
    End If
    If EndDay > 30 Then
      EndDate = DateAdd("d", -1, EndDate)
    End If
  End If
  StartDay = Day(StartDate)
  EndDay = Day(EndDate)
  TempMonths = DateDiff("M", StartDate, EndDate)
  Days360 = (TempMonths * 30) + (EndDay - StartDay)
End Function
Hi Danny,

Thanks for your quick reply!

Another question, seems I can't figure out how to use this:

As fo
StartDay = Day(StartDate)
EndDay = Day(EndDate)

The both Day I changed
to:
StartDay = text20.text(StartDate)
EndDay = text21.text(EndDate)

As for in the form:
When button clicked:
text22.text = days360

How can i get this working?

Best regards
Hey iSmile,

have you tried to call the function with:
Code
text22.text  = Days360(text20.text, text21.text)
(Mar 27, 2015 11:37 AM)Danny233223_temp Wrote:  Hey iSmile,

have you tried to call the function with:
Code
text22.text  = Days360(text20.text, text21.text)

Thank you very much!

It actually worked ^^. +REP over here


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by AzokSep 23, 2014 02:30 PM 10 575 Sep 23, 2014 02:30 PM
Last Post: TheBarret
[.NET] by jcbulletJul 16, 2014 10:39 AM 7 413 Jul 16, 2014 10:39 AM
Last Post: __Digital__
[.NET] by pwntokenApr 23, 2014 01:29 PM 14 352 Apr 23, 2014 01:29 PM
Last Post: pwntoken