On Feb 23, 2006, at 9:02 PM, Eriko Arief wrote:
Dear Sir ,
I would like to ask , how to get the days in one month ? example
february have 28 days and march have 31 days.
i want the system can get the number of day automatically, please
advise.
Here's some simple pseudo-code
given: a month in String format "<mm>/<dd>/<yyyy>" in a variable, 's'
1) parse out the month part with Val(Left(s, 2)) into another variable
'Dim monthPart As Integer'
2) parse out the day part as above (dayPart = Val(Mid(s, 4, 2)), then
3) parse out the year part similarly.
4) Increment the month part by 1
5) If monthPart > 12 Then
6) yearPart = yearPart + 1
7) monthPart = 1
8) End If
9) Set the day part to 1.
10) Put this back in string form:
strDate = CStr(monthPart) + "/" + CStr(dayPart) + "/" +
CStr(yearPart)
11) Now convert this into an RB Date object with the Parse() method.
12) Subtract 82400 from its .totalseconds property (1 day's worth of
seconds)
13) Convert the resulting date back to a string again, then parse out
the days property as above in step
(2).
14) return that integer.
Here's what it's doing:
1) decompose the string date into integers that represent the day,
month, and year. (steps 1-3)
2) Add 1 to the month and check to see if in a new year; reflecting the
change in the year part if
necessary. (steps 4-8)
3) sets the day part to 1 so you get the 1st day of the next month
after the one in question. (step 9)
4) subtract 1 day, making the date the last day of the month you
specified. (steps 10-12)
5) grab the day part, and return it. (steps 13-14)
Thanks & B.Regards,
Eriko
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
William H Squires Jr
4400 Horizon Hill #4006
San Antonio, TX 78229
[EMAIL PROTECTED] <- remove the .nospam
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>