Windows Scripting
  Home arrow Windows Scripting arrow Page 2 - 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 - Beginning the script


    (Page 2 of 4 )

    The challenge also stated that the script should be written for (and would be tested using) the Cscript.exe engine.  For our purposes, I think it’s best to force the use of the Cscript.exe host by beginning our script with the following code.

    If LCase(Right(WScript.FullName, 11)) <> "cscript.exe" Then

        strPath = WScript.ScriptFullName

        strCommand = "%comspec% /k cscript " & Chr(34) & strPath & chr(34)

        CreateObject("WScript.Shell").Run(strCommand)

        WScript.Quit

    End If

    Very simply, this code snippet uses the WScript object’s FullName property to determine in which host engine the script is running.  If it is not Cscript, then the script calls itself from the command line in the proper engine, and then terminates itself.

    It is important that our script runs in Cscirpt.exe.  You saw in the example on the last page that the calendar spans several lines.  If the script were to run in Wscript.exe, each of these lines would result in a separate message box.  For obvious reasons, we don’t want that.

    If you really wanted to run this script in Wscript, you could.  Instead of outputting each line in the script, you would add a line feed character and append them in a single string.  This string could then be displayed in a message box.  However, message boxes do not use mono-spaced, so the columns would not line up properly.

    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