Use classes in VBScript (4)

zhaozj2021-02-16  91

The current code is still not practical from what we want, we will use class TVProgram in other pages, so it is best to independently define it so that all face can be called. Create an ASP page and name TVProgramClass.asp, we define the 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

Programdate = day (internal_programdate) & _

"" & Monthname (Month (Internal_ProgramDate) &_

"" & Year (internal_programdate)

End Property

Public property let progradate (byval vardatein)

If isdate (Vardatein) THEN

INTERNAL_PROGRAMDATE = VARDATEIN

END IF

End Property

Public ProgramTITE

END CLASS

%>

This allows us to call our defined classes in any ASP, the syntax is as follows: <%

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 has a suggestion. If you rename your included file .asp, and ensure that all important code is in <% ...%> , even if someone guesses you, there is no way to see the file name. Content!

转载请注明原文地址:https://www.9cbs.com/read-12996.html

New Post(0)