Creating objects
When you create an object type (Class) in VBScript, you first have to know that it's really easy! I self-study in an afternoon, just read the Microsof VB Script reference book, but must admit that this book is not the easiest document to read.
Beginners need to install the VBScript 5.0 engine, which can be downloaded at the Microsoft ' s scripting site.
Let's look at the code. The definition of a class is very similar to a function and a child procedure. The Start behavior class <myclassname>, ending with End class, all object definitions written in the intermediary department. Now we can build the first class with what we've learned and not implement any functional classes.
Class 4GuysTestObject
End Class
This doesn't seem to be the case, but when you write the following code, you create an instance of the object:
Dim Objtestobject
Set Objtestobject = New 4GuysTestObject
Set Objtestobject = Nothing
Obviously, we can't do anything with objects right now, and now I'm going to explain how to define properties and methods in the object.
The most basic thing you can do with an object is to create a set of data. For example, if you want to set up a time, date, and video program title, you can create an object that contains the attributes "StartTime", "Programdate", and "Programtitle". The code is as follows:
Class Tvprogram
Public StartTime
Public programdate
Public Programtitle
End Class
Dim Objtvshow
Set objtvshow = New Tvprogram
Objtvshow.starttime = CDate ("17:30")
Objtvshow.programdate = DateSerial (1999,9,17)
Objtvshow.programtitle = "The Jerry Springer Show"
Response.Write Objtvshow.programtitle & "are on" & _
Objtvshow.starttime & "on" & Objtvshow.programdate