Using classes in VBScript (iv)

Source: Internet
Author: User
Tags define end include
Vbscript|vbscript Now the code is somewhat less practical than we want, we'll use class Tvprogram on other pages, so it's best to define it separately so that all faces can be invoked. Create an ASP page and name it tvprogramclass.asp, where we define class Tvprogram.

--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

%>

This allows you to call our defined classes in any ASP, as follows:

<!--#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 in <%= objtvshow.starttime%> on <%= objtvshow.programdate%>.



Here's a suggestion. If you rename your include file. asp, and ensure that all important code is in <code><% ...%>< code>, then even if someone guessed the file name you included, you can't see the contents!



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.