VBS_3 – Functions

There are many built in functions in VBScript.  A function is a block of code that performs a task and then returns a value.  Functions are pre-defined  and can be used by simply calling on their name.

Date and Time Functions
There are many built-in functions in VBScript for working with numbers, dates, and times.

  • Date – returns the system date
  • Timereturns the system time
  • Nowreturns the current date and time

Example Code:

DIM currentTimeSingle

currentTImeSingle = TIme
msgbox currentTimeSingle

Note : in terms of code – there is nothing special about the name of the variable- it could have been anything.  The name chosen is to communicate to people who read the code so they know what it is and what type it is.



After working through the above example…

Use Notepad++ or some such program and create a script that:

  • Declares a variable called dateSingle
  • Assign the Date function to the dateSingle variable
  • Displays a message box with the message, “The current date is: current date”  Where “current date” is the actual date.

Save your script file and run it to test it.  Then hand in your code as a .txt file.


Leave A Reply

Your email address will not be published. Required fields are marked *