⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 default.aspx

📁 This is a book about vb.you could learn this from this book
💻 ASPX
字号:
<%@Page Language="VB"%>

<script runat=server>

	' Defines a product

	Public Class Product

		' Private members

		dim _code as string 
		dim _description as string
		dim _price as Double

		' Constructor

		Sub New( initialCode as String, _
						initialDescription as String, _
						initialPrice as Double  )

			Code = initialCode
			Description = initialDescription
			Price = initialPrice

		End Sub

		Public Property Description as String

			Get
				Description = _description
			End Get

			Set
				_description = Value
			End Set
			
		End Property

		Public Property Code as String

			Get
				Code = _code
			End Get

			Set
				_code = Value
			End Set
			
		End Property


		Public Property Price as Double

			Get
				Price = _price
			End Get

			Set
				_price = Value
			End Set
			
		End Property
			
	End Class

	' Define a Products Collection

	Public Class ProductCollection 

		Implements IEnumerable

		dim _products as Hashtable

		Public Sub New()
			_products = new Hashtable()
		End Sub

		' Implement an enumerator for the products

		Public Function GetEnumerator() As IEnumerator _
			Implements IEnumerable.GetEnumerator

			GetEnumerator = _products.Values.GetEnumerator()
		End Function

		
		Public Default Property Item(Code as String) as Product
			Get
				Item = CType( _products(Code), Product )

			End Get

			Set
				Add(Value)
			End Set
		End Property
		
		Public Sub Add( Item as Product )
			if Item is Nothing then
				throw new ArgumentException("Product can not be null")
			end if

			_products.Add(Item.Code,Item)
		End Sub

		Public Sub Remove( Item as Product )
			_products.Remove( Item.Code )
		End Sub

	End Class


	Protected Sub Page_Load( sender as object, events as EventArgs )
	End Sub


	dim _products as ProductCollection = new ProductCollection

</script>

<%

	' List products where the price is greater than 40 dollars


	dim products as ProductCollection
	dim p as product

	products = new ProductCollection()

	p = new Product("CAR", "A New Car", 19999.99 )
	products.Add( p )

	p = new Product("HOUSE", "A New House", 299999.99 )
	products.Add( p )

	p = new Product("BOOK", "A New Book", 49.99 )
	products( p.Code ) = p


	Response.Write("<h4>Product List</h4>")

	for each p in products
		Response.Write (p.Code & "-" & p.Description & "-" & p.Price )
		Response.Write("<BR>")
	next 

	products.Remove( products("HOUSE") )

	Response.Write("<h4>Product List (HOUSE removed)</h4>")

	for each p in products
		Response.Write (p.Code & "-" & p.Description & "-" & p.Price )
		Response.Write("<BR>")
	next 

	Response.Write("<p>")

	Response.Write("<BR>Description for code CAR is:" & _
	                products("CAR").Description )

%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -