I want to make visual basic display the past 6 months (i.e. october, september, august and back). I also want Visual Basic to advance the months automatically. Does anyone know how to do that?
How do I make Visual Basic display the past 6 months and then update itself automatically as the months moveon
Drop this VBScript into an ASP page on an webserver. You can easily adapt this to a VB Winform app. Here is the code:
%26lt;%
For i = 4 to 10
response.write WriteMonth(i, 2006)
Next
For i = 11 to 12
If DateDiff( "d",Now, DateSerial( 2006, i, 1 )) %26lt;= 0 Then 'is past the date
response.write WriteMonth( i, 2006 )
End If
Next
'get the year
theYear = Year(Now)
'if the year is after 2006 then we will need to start the year of months again
If theYear %26gt;= 2007 Then
For i = 1 to 12
If DateDiff( "d", Now, DateSerial( theYear, i, 1 )) %26lt;= 0 Then 'is past the date
response.write WriteMonth( i, theYear )
End If
Next
End If
Function WriteMonth( theMonth, theYear )
WriteMonth = MonthName( Month( DateSerial( theYear, theMonth, 1 ))) %26amp; " "
End Function
%%26gt;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment