To read the article online, visit

Using Classes within VBScript, Part 4

By Mark Lidstone

Since our code is starting to get a bit unwieldy for what we want, and we want to be able to use the TVProgram class in other pages, it makes sense to put the TVProgram class definition in it's own file and include it in all the pages where it is needed. We'll create an ASP page named TVProgramClass.asp that will contain the class definition for our TVProgram class.

<% Class TVProgram Private internal_StartTime Public Property Get StartTime StartTime = Hour(internal_StartTime) & _ ":" & Minute(internal_StartTime) End Property Public Property Let StartTime(ByVal varTimeIn) If IsDate(varTimeIn) Then internal_StartTime = varTimeIn End If End Property Private internal_ProgramDate Public Property Get ProgramDate ProgramDate = Day(internal_ProgramDate) & _ " " & MonthName(Month(internal_ProgramDate)) & _ " " & Year(internal_ProgramDate) End Property Public Property Let ProgramDate(ByVal varDateIn) If IsDate(varDateIn) Then internal_ProgramDate = varDateIn End If End Property Public ProgramTitle End Class %>

Now, we can include our class definition inside any ASP page, using syntax like:

<!-- #include virtual="TVProgramClass.asp" -->
<% Dim objTVShow Set objTVShow = New TVProgram objTVShow.StartTime = CDate("17:30") objTVShow.ProgramDate = DateSerial(1999,9,17) objTVShow.ProgramTitle = "The Jerry Springer Show" %>

<%= objTVShow.ProgramTitle %> is on at <%= objTVShow.StartTime %> on <%= objTVShow.ProgramDate %>.

Here's a quick tip for you. If you rename your include files .asp and make sure all the important stuff is inside the code delimiters , then if someone guesses your include file name they won't be able to see the code inside! For a more detailed discussion of include files, be sure to read The low-down on inlcudes!

Happy Programming!

  • Read Part 1 | Part 2 | Part 3


  • Download the source to TVProgramClass.asp in text format

  • Article Information
    Article Title: - Using Classes within VBScript
    Article Author: Mark Lidstone
    Published Date: Thursday, September 23, 1999
    Article URL:

    Copyright 2018 QuinStreet Inc. All Rights Reserved.
    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers