Sometimes it is useful to create your own Classes and Objects (an instantiation of a class) in ASP, below is the basic code to create one.
Class Person
Public Function IntroduceYourself()
Response.Write("Hello, my name is " & Name & ", it's nice to meet you!")
End Function
Public Name
End Class
The above code declares a class. This class has one Public member - Name and one Public function - IntroduceYourself.
To use this class:
Set Adam = new Person //Create Adam object using the Person class. Adam.Name = "Adam" //Set Name property. Adam.IntroduceYourself() //Call the IntroduceYourself method.
Set Adam = new Person creates an Object of type Person and assigns it to the variable name Adam. Adam.Name ="Adam" assigns the string "Adam" to the Adam-Person Object's Name attribute. Adam.IntroduceYourself calls the Adam-Person Objects IntroduceYourself function. The output of this little demo should politely say Hello, my name is Adam, it's nice to meet you!
Complete Example
Here is a complete example within a single HTML page. Notice I declared the class at the end of the HTML to show you that where you define your class is not important. Usually developers put classes into their own files.
<html> <head> <title>Test Page</title> </head>
<body>
<h1>Introduce Yourself</h1> <% Set Adam = new Person //Create Adam object using the Person class. Adam.Name = "Adam" //Set Name property. Adam.IntroduceYourself() //Call the IntroduceYourself method. %>
</body>
</html> <% Class Person Public Function IntroduceYourself() Response.Write("Hello, my name is " & Name & ", it's nice to meet you!") End Function
2014 and I'm just getting into classes! Our site was build with Classic ASP and has grown since; in too deep to change now! My programming skills have evolved and I came to classes as a result of frustration at trying to pick my way through my old code. This super-simple example has got me up and running. Wish I'd found it years and years ago!
Thank you for having written it Adam, your post is still doing great service.
Store and all web are assumed for the main idea for the turns. The goals of the team and look at this web-site for the changes. All the options re objected for the citizens. The style is issued for the main ideal support for the turns for all people.