Results 1 to 5 of 5

Thread: [RESOLVED] Calendar issues

  1. #1

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Resolved [RESOLVED] Calendar issues

    I need a function that takes a month and year as input and returns the number of days for that month. Or preferably, a function that takes a year as input and tells whether it's a leap year or not.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  2. #2
    Addicted Member
    Join Date
    Mar 2008
    Posts
    143

    Re: Calendar issues

    if you are asking for an inbuilt function to find leap year in vb6 then it is not available you have to write your own , same to do with the number of days

  3. #3
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Calendar issues

    For a leap year function, this should work
    Code:
    Private Sub Form_Load()
        MsgBox "2008 = " & IsLeapYear(2008)
        MsgBox "2009 = " & IsLeapYear(2009)
    End Sub
    
    Private Function IsLeapYear(ByVal iYear As Integer) As Boolean
    Dim strDate As String
    
        strDate = "February 29, " & iYear
        IsLeapYear = IsDate(strDate)
    End Function

  4. #4

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Calendar issues

    Quote Originally Posted by sansknowledge View Post
    if you are asking for an inbuilt function to find leap year in vb6 then it is not available you have to write your own , same to do with the number of days
    Yes I know how to calculate it, just wanted to avoid all those formulas. I thought since there's a calendar control there could be something similar in terms of a function.
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

  5. #5

    Thread Starter
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    Re: Calendar issues

    Quote Originally Posted by MarkT View Post
    For a leap year function, this should work...
    Yes it works, only I had to make minor changes to adapt it to the Spanish date format:
    VB Code:
    1. Private Function IsLeapYear(ByVal iYear As Integer) As Boolean
    2.     Dim strDate As String
    3.  
    4.     strDate = "29-2-" & CStr(iYear)
    5.     IsLeapYear = IsDate(strDate)
    6.    
    7. End Function
    Lottery is a tax on people who are bad at maths
    If only mosquitoes sucked fat instead of blood...
    To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width