S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Visual Basic Study #2 April 06, 2004 Kim, Ki Young

Slides:



Advertisements
Similar presentations
ISOM3230 Business Applications Programming
Advertisements

Lecture Set 4 Data Types and Variables Part B – Variables, Constants, Expressions Conversion Rules Options Strict, Option Explicit Scope of Definition.
COEN Expressions and Assignment
Gary MarsdenSlide 1University of Cape Town Statements & Expressions Gary Marsden Semester 2 – 2000.
More about classes and objects Classes in Visual Basic.NET.
Introduction to the C# Programming Language for the VB Programmer.
PSU CS 106 Computing Fundamentals II VB Statements HM 5/19/2008.
CS 3850 Lecture 5 Operators. 5.1 Binary Arithmetic Operators Binary arithmetic operators operate on two operands. Register and net (wire) operands are.
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
JavaScript, Third Edition
Compunet Corporation1 Programming with Visual Basic.NET Arithmetic, Logical & Bitwise Operators Week # 3 Tariq Ibn Aziz.
Object-Oriented Programming in Visual Basic.NET. Overview Defining Classes Creating and Destroying Objects Inheritance Interfaces Working with Classes.
Object-Oriented Programming: Inheritance
Performing Simple Calculations with C# Svetlin Nakov Telerik Corporation
To define a class in Visual Basic.NET, you can follow this general procedure: 1. Add a class to the project. 2. Provide an appropriate file name for.
S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Visual Basic Study #1 April 01, 2004 Nam, Sedong
Inheritance Chapter 14. What is inheritance?  The ability to create a class from another class, the “parent” class, extending the functionality and state.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 1A) UTPA – Fall 2011.
Ryan Chu. Arithmetic Expressions Arithmetic expressions consist of operators, operands, parentheses, and function calls. The purpose is to specify an.
Why to Create a Procedure
CSCI 3327 Visual Basic Chapter 6: Methods: A Deeper Look UTPA – Fall 2011.
2440: 211 Interactive Web Programming Expressions & Operators.
Language Elements 1. Data Types 2 Floating Point (real) Single Precision Double Precision Decimal Fixed Point (integer) Byte Short Integer Long Numerical.
Chapter 3: Data Types and Operators JavaScript - Introductory.
Operators Using Java operators An operator takes one or more arguments and produces a new value. All operators produce a value from their.
Programming Pillars Introduction to Object- Oriented Programming.
1 Session 3: Flow Control & Functions iNET Academy Open Source Web Programming.
 2002 Prentice Hall. All rights reserved. 1 Chapter 9 – Object-Oriented Programming: Inheritance Outline 9.1Introduction 9.2 Base Classes and Derived.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
S ystem P rogrammers' A ssociation for R esearching C omputer S ystems 3. Operators SPARCS JAVA Study.
Visual Basic IITG to be expanded. What is Visual Basic? Object Oriented Programming Language (OOP) Graphical User Interface (GUI) Event Driven – Write.
VBScript Language. What is VBScript Based on the Visual Basic family of languages Supports object oriented features Interpreted Loosely Typed Implicitly.
C# EMILEE KING. HISTORY OF C# In the late 1990’s Microsoft recognized the need to be able to develop applications that can run on multiple operating system.
CompSci 100E 2.1 Java Basics - Expressions  Literals  A literal is a constant value also called a self-defining term  Possibilities: o Object: null,
EIW - ASP Introduction1 Active Server Pages VBScript.
VB .NET Revisit VB .NET Revisit.
Applications Development
Boolean Logic Logical Operators Comparison Operators Truth tables.
Programming in Java CSCI-2220 Object Oriented Programming.
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
Object-Oriented Application Development Using VB.NET 1 Chapter 8 Understanding Inheritance and Interfaces.
C# Operator Overloading and Type Conversions C#.NET Software Development Version 1.0.
Introduction to Programming Lecture Note - 2 Visual Basic Programming Fundamentals.
Visual Basic Programming I 56:150 Information System Design.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
CIVIL AND GEOMATIC ENGINEERING FT Okyere. CIV 257- COMPUTER PROGRAMMING Lecture 3.
By Mr. Muhammad Pervez Akhtar
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
Object-Oriented Programming: Inheritance and Polymorphism.
Chapter 2 11/18/2015 © by Pearson Education, Inc. All Rights Reserved. Lect9 GC 2011.
ILM Proprietary and Confidential -
Object-Oriented Programming: Classes and Objects Chapter 1 1.
Presentation By :- Nikhil R. Anande ( ) Electronic & Communication Engineering. 3 nd Year / 5 th Semester FACULTY GUIDE : RAHIUL PATEL SIR MICROCONTROLLER.
These materials where developed by Martin Schray
VISUAL BASIC 6.0 Designed by Mrinal Kanti Nath.
Object-Oriented Programming: Classes and Objects
C# Operator Overloading and Type Conversions
University of Central Florida COP 3330 Object Oriented Programming
University of Central Florida COP 3330 Object Oriented Programming
Method.
Object-Oriented Programming: Classes and Objects
Object-Oriented Programming: Inheritance
Object-Oriented Programming: Inheritance
Conditional Statements
Object-Oriented Programming: Inheritance
Languages and Compilers (SProg og Oversættere)
Intro to Programming Concepts
Classes & Objects A deeper Look Chapter 10 & 11
Problem 1 Given n, calculate 2n
Object-Oriented Programming: Inheritance
Presentation transcript:

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Visual Basic Study #2 April 06, 2004 Kim, Ki Young Visual Basic Study Group SPARCS ( / KAIST ( 그림 :

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems 목차 2. The Visual Basic.NET Language Assignment Operators and Expressions Statements Classes Interfaces We ’ ll be back ….

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Assignment Variable, field, or property = expression – 늘 해왔던 대로 … Value type –Expression 의 value 를 copy Reference type –Value 의 reference 를 저장

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Operators & Expressions Unary operators Binary operators Prefix notation –The operator precedes the operand –Unary operators Infix notation –The operator is between the operands –Binary operators –TypeOf.. Is??

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems O&E : Unary Operators +, - Not –Logical negation –Takes a Boolean operand AddressOf –Returns a reference to a method

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems O&E : Arithmetic Operations +, -, *, / \ (Integer division) –Integer operands –Rounded to the integer nearest to zero Mod –Modulo ^ –Exponentiation

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems O&E : Relational Operators, String-Concatenation Operators =, <>,, = TypeOf … Is –TypeOf Is –Return value : Boolean Is –Check if the references refer to the same object Like –Pattern Matching –?, *, #, [] String Concatenation –&, +

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems O&E : Bitwise Operators, Logical Operators And, Or, Xor, Not AndAlso –Check if both operands are True –Logical short-circuiting OrElse –Check if either or both operands are True –Logical short-circuiting Logical Operators –Boolean operands –And, Or, Xor, Not

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems O&E : Operator Precedence CategoryOperator Arithmetic and concatenation Exponentiation Negation Multiplication and division Integer division Modulus arithmetic Addition and subtraction, + & Comparison Operation … Logical and bitwise operators Negation (Not) Conjunction (And, AndAlso) Disjunction (Or, Orelse, Xor)

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems O&E : Operator Overloading.NET Framework Supports Operator Overloading, But current version of Visual Basic.NET doesn ’ t support operator overloading C# 으로 된 component 를 읽을 경우 ? – 다른 method 를 통해 같은 기능을 제공해야 함

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Statements Line breaks 를 통해 statement 가 끝남 여러 줄에 걸쳐 한 statement 를 작성할 경우 한 줄에 여러 statement 를 작성할 경우 : colon(:) Dim strSql As String = “SELECT Customers.CompanyName,” _ & “ COUNT(Orders.OrderID) AS OrderCount” _ & “ FROM Customers INNER JOIN Orders” _ … i = 5 : j = 10

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Statements : Option Statements BinaryOption Compare [Binary | Text] –Binary : Case-sensitive –Text : Case-insensitive OnOption Explicit [On | Off] –Decide if all variables need to be declared OffOption Strict [On | Off] –Check Type Conversion

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Statements : Branching Statements(1/3) Call() –Redundant!!! Exit –Exit Do –Exit For –Exit Function –Exit Property –Exit Sub –Exit Try

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Statements : Branching Statements(2/3) Goto – 여기서도 쓰지 않는 쪽을 권장 If If expression Then statements ElseIf expression Then statements ElseIf expression Then statements Else statements End If

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Statements : Branching Statements(3/3) RaiseEvent –Fires the given event Return –Exits a function and provides a return value Select Case Select Case strColor Case “red” ‘... Case “green”, “blue”, strSomecolor ‘... Case “purple” To “sky” ‘... Case Else ‘... End Select

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Statements : Iteration Statements Do For For Each Do While i<10 ‘... Loop ‘ Do Until i>=10 ‘... Loop ‘ Do ‘... Loop While i<10 ‘ Do ‘... Loop For i = 1 To 10 For j = 1 To 10 For k = 1 To 10 ‘... Next k, j, i Dim a() As Integer = {1, 2, 3, 4, 5} Dim b As Integer For Each b In a ‘... Next

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Class : Object Instantiation and New 세 가지 방법이 모두 같은 결과 Imports System.Collections ‘No.1... Dim ht As Hashtable ht = New Hashtable() ‘No.2... Dim ht As Hashtable = New Hashtable() ‘No.3... Dim ht As New Hashtable()

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Class : Constructors Class 안에 New 라는 키워드를 통해 정의 Public Class SomeClass Dim m_value As Integer Public Sub New() m_value = Date.Today.Day ‘MyClass.New(Date.Today.Day) makes same result. End Sub Public Sub New(ByVal InitialValue As Integer) m_value = InitialValue End Sub End Class

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Class : Inheritance Class 는 Inherits 를 통해, Methods 는 Overrides 를 통해 상 속받는다. MustInherit : Instantiate 될 수 없음 MustOverride : derived class 에서 구현되어야 함 Parent Class 는 MyBase 를 통해 접근 Public Class Square Inherits Shape Public Overrides Sub Draw() ‘... End Sub End Class MyBase.New()

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Class : Methods Subroutines Functions [method_modifiers] Sub [attribute_list] _ method_name ([parameter_list]) [handles_or_implements] [method_body] End Sub [method_modifiers] Function [attribute_list] _ method_name ([parameter_list]) [As type_name] _ [handles_or_implements] [method_body] End Function

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Class : Method Parameters Parameter List Parameter 의 구성 [Optional] [ParamArray] [ByRef | ByVal] [attribute_list] _ parameter_name [As type_name] [ = constant expression] Parameter {, Parameter}

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Class : Main Method Compile 될 때 Main 이란 method 를 찾는다. Class 안에 있을 경우, Shared 로 되어있어야 한다. –Module 안에 있을 경우 Shared 라는 Keyword 가 필요 없음 여러 개의 Main 함수가 있을 경우 /main:

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Class : Implementing interface methods Implements 라는 keyword 사용 Public Class SomeClass Implements Icomparable Public Function CompareTo( _ ByVal obj As Object _ ) As Integer Implements Icomparable.CompareTo ‘... End Function End Class

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Class : Overloading 같은 기능, 다른 argument? – 굳이 함수 이름을 여러 개로 쓸 필요가 없다 Overloads? Overrides? Public Function SquareRoot(ByVal Value As Long) As Double ‘... End Function Public Function SquareRoot(ByVal Value As Double) As Double ‘... End Function

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Class : Shadowing Overloads Overrides => Shadows Public Class BaseClass Public Overridable Sub SomeMethod() ‘... End Sub Public Overridable Sub SomeMethod(ByVal i As Integer) ‘... End Sub End Class Public Class DerivedClass Inherits BaseClass Public Overloads Overrides Sub SomeMethod() ‘ = Public Shadows Sub SomeMethod() ‘... End Sub End Class

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Class : Property(1/2) Members that accessed like fields but are actually method calls Property Modifiers [property modifiers] Property [attributes] Property_name _ ([parameter list]) [As Type_Name] [implements list] [getter] [setter] End Property [Default] [access modifier] [override modifier] _ [overload modifier] [shared modifier] [read/write modifier]

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Class : Property(2/2) Public Property Center() As Point Get Dim retval As Point retval.X = Origin.X + (Size.XExtend \ 2) retval.Y = Origin.Y + (Size.YExtend \ 2) End Get Set Dim currentCenter As Point = Center Origin.X += Value.X – currentCenter.X Origin.Y += Value.Y – currentCenter.Y End Set End Property

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Class : The Me and MyClass Keywords Me, MyClass – 스스로의 Class 를 가리키는 keyword –MyClass 는 member access 에만 쓰일 수 있다. –Me 는 shared method 에서는 사용할 수 없다. Public Class BaseClass Public Sub Method1() Me.Method2() MyClass.Method2() End Sub Public Overridable Sub Method2() Console.WriteLine(“BaseClass.Method2”) End Class Public Class DerivedClass Inherits BaseClass Public Overrides Sub Method2() Console.WriteLine(“DeriveClass.Method2”) End Sub End Class

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Interfaces Interface 와 Class 의 member 의 이름이 일치할 필요 없음 Interface 상에 없는 member 도 Class 상에서 정의해줄 수 있음 한 Class 가 여러 Interface 를 상속받을 수 있음 Public Interface ISomeInterface Sub SomeSub() Function SomeFunction() As Integer Property Someproperty() As String Event SomeEvent( _ ByVal sender As Object, _ ByVal e As SomeEventArgs ) End Interface

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems To Be Continued … 제목 : Visual Basic Study #3 발표 : 전현우 일시 : 다음주 초 ? 내용 : –2. The Visual Basic.NET Language Structures Enumerations Exceptions Delegates Events Standard Modules …