When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sections:
Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
XML Info
Information:
Feedback
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Thursday, September 23, 1999

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.

- continued -

--TVProgramClass.asp--
<% 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


    Attachments:

  • Download the source to TVProgramClass.asp in text format


  • ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article