Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > ASP > ASP/VBScript Class > ASP/VBScript - Class Introduction



Clound SSD Virtual Server

ASP/VBScript - Class Introduction

ASP/VBScript Class ความหมาย Class คือแบบร่างที่ถูกออกแบบไว้สำหรับการ ทำงานใดทำงานหนึ่ง ในกลุ่มของคำสั่งที่เกี่ยวข้องกัน ซึ่งใน Class เองจะประกอบด้วย Method/Function หลาย ๆ Method และมี Property ที่ไว้รับตัวแปรจากภายนอก ในภาษา VBScript เองการใช้งาน Class เป็นเรื่องง่ายมาก และไม่มีความซับซ้อนเลย และสามารถทำความเข้าใจได้อย่างง่ายได้


Syntax

<%
Class Class_Name

'*** Variable ***'
Dim strVar 
Dim strMyProperty

'*** Left Property ***'
Property Get MyProperty (MyProperty)
  strMyProperty = MyProperty 
End Property

'*** Get Property ***'
Property Get sMyProperty 
  sMyProperty  = strMyProperty 
End Property

'*** Method Function ***'
Function MyFunction
....
End Fuction

'*** Method Sub ***'
Sub MySub
....
End Sub 

End Class
%>


ถ้ายังไม่เข้าลองมาดูตัวอย่างดีกว่าครับ


Sample

<html>
<head>
<title>ThaiCreate.Com ASP  Class</title>
</head>
<body>
<%	
	Class MyClass		
		Private strFullName
		Private strFirstName
		Private strLastName

		'*** Let Property (รับตัวแปรจาก Properties) ***'
		Public Property Let FirstName(sFirstName)	'*** Property FirstName ***'
		  strFirstName = sFirstName
		End Property
		Public Property Let LastName(sLastName) '*** Property LastName ***'
		  strLastName = sLastName
		End Property
		
		'*** Get Property (อ่านตัวแปรจาก Property (strFirstName,strLastName) ) ***'
		Public Property Get vFirstName
		  vFirstName = strFirstName
		End Property
		Public Property Get vLastName
		  vLastName  = strLastName
		End Property
		
		'*** Method MyName ***'
		Public Function MyName				 		 
			 strFullName  = strFirstName & " " & strLastName
			 MyName = strFullName
		End Function
		
		'*** Method WriteMyName ***'
		Public Sub WriteMyName			
			 Response.write strFullName
			 Response.write "<br>" & vFirstName & " " & vLastName  
		End Sub


	End Class
	
	'*** New Class ***'
	Dim MyCls,strMyFullName
	Set MyCls =  New MyClass
	MyCls.FirstName = "Mr.Weerachai"
	MyCls.LastName  = "Nukitram"
	strMyFullName = MyCls.MyName()
	MyCls.WriteMyName() 
 
	Response.write("<hr>")

	Response.write "strMyFullName = " & strMyFullName
%>
</body>
</html>

Screenshot

ASP/VbScript Class


ตัวอย่างการใช้งาน Class กับ Database








   
Share


ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท


ลองใช้ค้นหาข้อมูล


   


Bookmark.   
       
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2008-08-10 15:43:15 / 2008-12-14 17:50:38
  Download : Download  ASP/VBScript - Class Introduction
 Sponsored Links / Related

 
ASP/VBScript - Class_Initialize() & Class_Terminate()
Rating :

 
ASP/VBScript - Private & Public Statement
Rating :

 
ASP/VBScript - Property Get & Property Let
Rating :


ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่