|
-
Apr 21st, 2009, 10:57 AM
#1
[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)
-
Apr 21st, 2009, 11:12 AM
#2
Addicted Member
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
-
Apr 21st, 2009, 11:20 AM
#3
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
-
Apr 21st, 2009, 11:24 AM
#4
Re: Calendar issues
 Originally Posted by sansknowledge
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)
-
Apr 21st, 2009, 11:31 AM
#5
Re: Calendar issues
 Originally Posted by MarkT
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:
Private Function IsLeapYear(ByVal iYear As Integer) As Boolean Dim strDate As String strDate = "29-2-" & CStr(iYear) IsLeapYear = IsDate(strDate) 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|