Visual Web Development



Similar documents
CRM Setup Factory Installer V 3.0 Developers Guide

Many applications consist of one or more classes, each containing one or more methods. If you become part of a development team in industry, you may

ResellerPlus - Bulk Http API Specification. (This Document gives details on how to send messages via the Bulk HTTP API for the RouteSms SMPP System)

Lab 8: ASP.NET 2.0 Configuration API and Health Monitoring

TRANSITION FROM TEACHING VB6 TO VB.NET

Hands-On Lab. Client Workflow. Lab version: Last updated: 2/23/2011

VB.NET - CLASSES & OBJECTS

Hands-On Lab. Building a Data-Driven Master/Detail Business Form using Visual Studio Lab version: Last updated: 12/10/2010.

VB.NET - WEB PROGRAMMING

Xml Inst2 Page - Complete Education

A SharePoint Developer Introduction. Hands-On Lab. Lab Manual SPCHOL306 Using Silverlight with the Client Object Model VB

J a v a Quiz (Unit 3, Test 0 Practice)

ACE 2011 International. Role Based Clients. aras.com

Hi, processing. Code of the vb.net version. Imports System.Data Imports System.Data.SqlClient

Ambientes de Desenvolvimento Avançados

ClientAce WPF Project Example

TECHNOLOGY Computer Programming II Grade: 9-12 Standard 2: Technology and Society Interaction

WORKSPACE WEB DEVELOPMENT & OUTSOURCING TRAINING CENTER

5 Point Choice ( 五 分 選 擇 題 ): Allow a single rating of between 1 and 5 for the question at hand. Date ( 日 期 ): Enter a date Eg: What is your birthdate

Visual Basic Programming. An Introduction

Appendix B - VoIP SARRA Source Codes and Cisco XML Objects

Getting Started with STATISTICA Enterprise Programming

webcrm API Getting Started

CRYSTAL REPORTS IN VISUAL STUDIO.NET 2003

How to Improve Database Connectivity With the Data Tools Platform. John Graham (Sybase Data Tooling) Brian Payton (IBM Information Management)

ResPage.aspx. Imports System.IO Imports System.Xml Imports System.Xml.XPath Imports System.Xml.Xsl Imports PDFDocScout

Deleting A Record Updating the Database Binding Data Tables to Controls Binding the Data Table to the Data Grid View...

Ch 7-1. Object-Oriented Programming and Classes

Introduction. Why (GIS) Programming? Streamline routine/repetitive procedures Implement new algorithms Customize user applications

CS 111 Classes I 1. Software Organization View to this point:

Form Tasarımı - 5. Veri Tabanı Veri tabanı ismi; m Tablo ismi; mt

THE CERN/SL XDATAVIEWER: AN INTERACTIVE GRAPHICAL TOOL FOR DATA VISUALIZATION AND EDITING

ASP.NET Dynamic Data

Facebook Twitter YouTube Google Plus Website

CSE 1020 Introduction to Computer Science I A sample nal exam

Java CPD (I) Frans Coenen Department of Computer Science

Visual Basic 2010 Essentials

'========================================================================== ==== Scans a range of A/D Input Channels

SRFax Fax API Web Services Documentation

EViews Database Extension Interface

CSI 2132 Lab 8. Outline. Web Programming JSP 23/03/2012

Library Intro AC800M

(Document Version 1.4) (This Document gives details on how to send messages via the Bulk HTTP API for the RouteSms SMPP System)

The University of Alabama in Huntsville Electrical and Computer Engineering CPE Test #4 November 20, True or False (2 points each)

Contents. 9-1 Copyright (c) N. Afshartous

Interactive Reporting er Manual

Data Transfer Tips and Techniques

The VB development environment

How To: Create a Crystal Report from ADO.NET Dataset using Visual Basic.NET

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Cluster APIs. Cluster APIs

Creating Datalogging Applications in Microsoft Excel

VB.NET INTERVIEW QUESTIONS

Java Application Developer Certificate Program Competencies

Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro

Basics of I/O Streams and File I/O

CONTROL OF MED INPUT/OUTPUT MODULES FROM OTHER LANGUAGES

Self-Service Portal Implementation Guide

Java Programming Language

Today s Outline. Computer Communications. Java Communications uses Streams. Wrapping Streams. Stream Conventions 2/13/2016 CSE 132

PIC 10A. Lecture 7: Graphics II and intro to the if statement

Hands-On Lab. Building Applications in Silverlight 4 Module 8: Advanced OOB and MEF. Event Administrator Dashboard

Introduction to Visual Basic and Visual C++ Database Foundation. Types of Databases. Data Access Application Models. Introduction to Database System

C# and Other Languages

CS506 Web Design and Development Solved Online Quiz No. 01

ACCESS Importing and Exporting Data Files. Information Technology. MS Access 2007 Users Guide. IT Training & Development (818)

Methodologies for Converting Microsoft Excel Spreadsheets to SAS datasets


C++ INTERVIEW QUESTIONS

USER GUIDE Appointment Manager

Siemens Applied Automation Page 1 11/26/03 9:57 PM. Maxum ODBC 3.11

IVI Configuration Store

Cohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT - BCNS/05/FT - BIS/06/FT - BIS/05/FT - BSE/05/FT - BSE/04/PT-BSE/06/FT

SPSS The Basics. Jennifer Thach RHS Assessment Office March 3 rd, 2014

Back Office User Guide

Creating a Windows Service using SAS 9 and VB.NET David Bosak, COMSYS, Kalamazoo, MI

Using the For Each Statement to 'loop' through the elements of an Array

Crystal Reports.NET Programming


Setting up a basic database in Access 2003

RARITAN VALLEY COMMUNITY COLLEGE ACADEMIC COURSE OUTLINE. CISY 105 Foundations of Computer Science

Commercial Database Software Development- A review.

MRA Data Transfer Catalogue (DTC) Change Proposal Form

Programming Languages CIS 443

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Lecture 5: Java Fundamentals III

Professional Services. Plant Applications SDK Guidelines GE FANUC AUTOMATION. Prepared by. Donna Lui Professional Services

Documentation to use the Elia Infeed web services

HOUR 3 Creating Our First ASP.NET Web Page

16.1 DataFlavor DataFlavor Methods. Variables

Progress Record. Seq. Lesson # Lesson Title Date Grade. Introduction to Computers (CORE COURSE) 1

Secrets of printf. 1 Background. 2 Simple Printing. Professor Don Colton. Brigham Young University Hawaii. 2.1 Naturally Special Characters

Transcription:

Terry Marris November 2007 Visual Web Development 17 Classes We see how to create our own classes. 17.1 The Concept My friend is: ann small - 1.52 metres female pretty and generous Attributes are derived from what an object has: in our example they include name, height, gender and character. Three friend objects might be: name = ann height = 1.52 gender = f name = sam height = 1.65 gender = m name = joy height = 1.55 gender = f Each object is distinct and all share the same attributes, but not necessarily with the same values. 1

A class represents the collection of similar objects, each sharing the same attributes. name height gender Friend A class has a name (Friend) and a set of attributes (name, height, gender). 17.2 The Specification The specification view of a class is concerned with the interface between its attributes and the outside world. In general access to attributes is controlled by operations. -name -height -gender Friend +setname(name) +getname() Setting operations update the values stored in attributes. Getting operations retrieve the values stored in attributes. setname() allows you to change a friend's name. getname() tells you what a friend's name is. The - sign indicates that the attributes are private and cannot be accessed by none Friend objects. The + sign indicates the operations are public and can be used by none Friend objects to access, in a controlled way, the private attributes. 2

17.3 The Implementation The class is named Friends. It is usual to use singular names for class names e.g. Friend not Friends. But Friend is a VB word. Public Class Friends The attributes are known as fields or instance variables in an implementation. Private name As String Private height As Double Private gender As Char New is a VB word and, in this context, defines a procedure that is responsible for constructing new instances (i.e. objects) of the Friends class. Public Sub New(ByVal name As String, ByVal height As Double, ByVal gender As Char) Me.height = height Me.gender = gender The Me qualifier is used to distinguish between the field names and the parameter names. getname() tells you what value is stored in an object's name attribute. Public Function getname() As String Return name setname() updates the value stored in an object's name attribute. Public Sub setname(byval name As String) 3

tostring() returns all the values stored in the fields as one long string. Public Overrides Function tostring() As String Return name & ", " & height & ", " & gender End Class We are obliged to use Override since tostring() is used by VB for other classes and we are providing our own specialised version. 17.4 Usage We create three new instances of the Friends class. Dim myfriend = New Friends("ann", 1.52, "f") Dim yourfriend = New Friends("sam", 1.65, "m") Dim ourfriend = New Friends("joy", 1.55, "f") And display them in a text box, each on their own line. txtfriends.text = myfriend.tostring() + ControlChars.CrLf + _ yourfriend.tostring() + ControlChars.CrLf + _ ourfriend.tostring() ControlChars.CrLf is a VB way of inserting a newline in text. Then we update ourfriend's name from joy to jon. ourfriend.setname("jon") And to confirm that the name was changed successfully we get and display ourfriend's name. txtfriends.text = txtfriends.text + ControlChars.CrLf + _ ourfriend.getname() 4

The entire code is shown below. Partial Class _Default Inherits System.Web.UI.Page Public Class Friends Private name As String Private height As Double Private gender As Char Public Sub New(ByVal name As String, ByVal height As Double, ByVal gender As Char) Me.height = height Me.gender = gender Public Function getname() As String Return name Public Sub setname(byval name As String) Public Overrides Function tostring() As String Return name & ", " & height & ", " & gender End Class Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim myfriend = New Friends("ann", 1.52, "f") Dim yourfriend = New Friends("sam", 1.65, "m") Dim ourfriend = New Friends("joy", 1.55, "f") txtfriends.text = myfriend.tostring() + ControlChars.CrLf + _ yourfriend.tostring() + ControlChars.CrLf + _ ourfriend.tostring() ourfriend.setname("jon") txtfriends.text = txtfriends.text + ControlChars.CrLf + _ ourfriend.getname() End Class 5

17.5 The Output The output from the code shown above in 17.4 above is: 17.6 Exercises 1. Try out the Friends program shown above. 2. Implement and test methods to update and retrieve the values stored in both height and gender. 17.7 Conclusion There is a lot more to classes than we have covered here. And you can have classes for as many different objects you can think of: bank accounts, library borrowers and weather statistics for example. But we have seen how to encapsulate data in objects and that an object is an instance of a class. Next, we look at dates. 6