Windows Scripting
  Home arrow Windows Scripting arrow Completing Calendars with VBScript Date Fu...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Completing Calendars with VBScript Date Functions
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-02-02

    Table of Contents:
  • Completing Calendars with VBScript Date Functions
  • Building the array
  • Completing the code
  • Validating user input

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Completing Calendars with VBScript Date Functions


    (Page 1 of 4 )

    In my last article, we began building a script that could produce and display a formatted calendar for a specified month and year. In this article, I’ll show you how to wrap up this project by putting all of the pieces together.We began our script by accepting a user’s input for the month and year.  We then used those two values to determine all of the other necessary values we would need, such as the first day of the month, the weekday that the first falls on, and the last day of the month.  Now we can complete the main portion of our script.

    We need to begin building an array to handle the dates involved in our calendar month.  This array will contain each day in the month.  I elected to house this in a separate function.

    arrThisMonth = BuildArray()

    The BuildArray function is only slightly complicated.  Let’s take a look at it in pieces.

    Function BuildArray()

       arrMonth = Array()

       intEmptyDays = intFirstWeekDay - 1

       For i = 1 To intEmptyDays

           ReDim Preserve arrMonth(UBound(arrMonth) + 1)

           arrMonth(UBound(arrMonth)) = "      "

       Next

    It begins by creating an empty dynamic array.  If you remember, a calendar week always begins on Sunday.  The first day of the month may not be on Sunday, so we need to determine the number of empty days before it.  Since the WeekDay function has returned an integer for the weekday of the first month, we can just subtract 1 from this value to determine the number of empty days in that week.

    For example, if Jan 1 were to appear on Thursday (a value of 5), there would be 5 minus 1, or 4, empty days preceding it: Sunday, Monday, Tuesday and Wednesday.

    More Windows Scripting Articles
    More By Nilpo


     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek