Windows Scripting
  Home arrow Windows Scripting arrow Page 3 - Building Calendars with VBScript Date Func...
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

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

    Table of Contents:
  • Building Calendars with VBScript Date Functions
  • Beginning the script
  • Finding the necessary dates
  • Calculating the remaining values

  • 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


    Building Calendars with VBScript Date Functions - Finding the necessary dates


    (Page 3 of 4 )

    Before we can do anything at all, our script needs to get the user’s input so that it can determine from what month and year the calendar needs to build.  There are two ways of doing this.

    strDate = InputBox("Please enter a month and year as MM/YYYY.", "Microsoft Scripting Games 2008")

    If strDate = "" Then WScript.Quit

    The most obvious is to use a simple input box to receive the user input as a string.  Notice in the second line that I’ve provided a little conditional statement that will end script execution if the user presses the cancel button.

    WScript.StdOut.Write "Please enter a month and year as MM/YYYY:"

    strDate = WScript.StdIn.ReadLine

    The second option relies on the fact that our script is running in Cscript.exe.  It uses the Standard Input and Output streams to receive the user’s input from within the command window.

    arrDateParts = Split(strDate, "/")

    intMonth = arrDateParts(0)

    intYear = arrDateParts(1)

    Regardless of which method you use, you should end up with the same type of string.  Now is a good time to break that into parts so that we have separate date and year values.  Since we know what character is being used to separate the values, VBScript’s Split function makes quick work of this, and the values can be assigned to variables in just a few simple lines.

    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 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek