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!



Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.