S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Visual Basic Study #1 April 01, 2004 Nam, Sedong

Slides:



Advertisements
Similar presentations
IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
Advertisements

Lecture Set 4 Data Types and Variables Part B – Variables, Constants, Expressions Conversion Rules Options Strict, Option Explicit Scope of Definition.
Visual Basic.NET Comprehensive Concepts and Techniques What’s new in VB.NET adapted from a presentation on Introduction to Visual Basic.NET by Jeff Quasney.
C#: Data Types Based on slides by Joe Hummel. 2 UCN Technology: Computer Science Content: “.NET is designed around the CTS, or Common Type System.
Introduction to the C# Programming Language for the VB Programmer.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
CVEV 118/698 Visual Basic Lecture 1 Prof. Mounir Mabsout Expert 1: Elsa Sulukdjian Expert 2: Walid El Asmar.
IS437: Fall 2004 Instructor: Dr. Boris Jukic Data Types, Constants, Variables, Scope, Conversion.
3. Data Types. 2 Microsoft Objectives “.NET is designed around the CTS, or Common Type System. The CTS is what allows assemblies, written in different.
Data Types and Operations Programming Fundamentals (Writing Code)Programming Fundamentals (Writing Code)
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
VB .NET Programming Fundamentals
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
VBA & Excel Barry L. Nelson IEMS 465 Fall Quarter 2003.
Platforms and tools for Web Services and Mobile Applications Introduction to C# Bent Thomsen Aalborg University 3rd and 4th of June 2004.
(c) Bob McKillop, 2006Tutorial #1 T1-1 Tutorial #1 - your first compiled code  the learning objectives for this tutorial are very modest q compile and.
Overview of Microsoft.Net and Vb.Net ITSE 2349 Spring 2002 Material from Microsoft.Net an Overview for ACC faculty by Stuart Laughton and Introduction.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Variables and Constants
Module 1: Introduction to C# Module 2: Variables and Data Types
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
Microsoft Visual Basic 2005: Reloaded Second Edition
Introduction to .NET Framework
Variable, Expressions, Statements and Operators By: Engr. Faisal ur Rehman CE-105 Fall 2007.
Language Elements 1. Data Types 2 Floating Point (real) Single Precision Double Precision Decimal Fixed Point (integer) Byte Short Integer Long Numerical.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Programming in C#. I. Introduction C# (or C-Sharp) is a programming language. C# is used to write software that runs on the.NET Framework. Although C#
Introduction to C# C# is - elegant, type-safe, object oriented language enabling to build applications that run on the.NET framework - types of applications.
Week 1: THE C# LANGUAGE Chapter 1: Variables and Expressions ➤ Included in Visual Studio.NET ➤ What the.NET Framework is and what it contains ➤ How.NET.
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.
C# D1 CSC 298 Elements of C# code (part 2). C# D2 Writing a class (or a struct)  Similarly to Java or C++  Fields: to hold the class data  Methods:
Dani Vainstein1 VBScript Session 1. Dani Vainstein2 Subjets for Session 1 Vbscript fundamentals. Variant subtypes. Variables. Option Explicit statement.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
VB .NET Revisit VB .NET Revisit.
Applications Development
Compunet Corporation1 Programming with Visual Basic.NET Fundamentals of Programming Lecture # 1 Tariq Ibn Aziz.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC PROGRAMMING FUNDAMENTALS Bilal Munir Mughal 1 Chapter-8.
1 Working with Data Structures Kashef Mughal. 2 Chapter 5  Please review on your own  A few terms .NET Framework - programming model  CLR (Common.
Chapters 2 & 3. .NET Software development model that allows applications created in disparate programming languages to communicate Universal data access.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Three Memory Locations and Calculations.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Programming with Microsoft Visual Basic th Edition
Object Oriented Software Development 4. C# data types, objects and references.
Session 1 C# Basics.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
VB.NET 2008 Introduction to Variables Part 1. Overview.NET Languages –Source Code –Compiler –MSIL –CLR & Windows Variables –Data Types –Converting.
CHAPTER THREE Representing Data: Constants and Variables.
INTRODUCTION CHAPTER #1 Visual Basic.NET. VB.Net General features It is an object oriented language  In the past VB had objects but focus was not placed.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
ILM Proprietary and Confidential -
CIS 338: VB Variables Dr. Ralph D. Westfall April, 2011.
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
Chapter 3 - VB 2008 by Schneider1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Introduction C# program is collection of classes Classes are collection of methods and some statements That statements contains tokens C# includes five.
CSE 110: Programming Language I Matin Saad Abdullah UB 1222.
D OTNET ONLINE TRAINING. DOTNET Online Training Course Content : Introduction to.Net Online Training NET FUNDAMENTALS Why Dot Net? The Dot Net initiative.
IS 350 Course Introduction. Slide 2 Objectives Identify the steps performed in the software development life cycle Describe selected tools used to design.
.NET MCQs MULTIPLE CHOICE QUESTION
Basic Introduction to C#
VBScript Session 1 IT Professional Academy.
Java Primer 1: Types, Classes and Operators
Data Types, Arithmetic Operations
2. Understanding VB Variables
Introduction to C# AKEEL AHMED.
.NET and .NET Core 5.2 Type Operations Pan Wuming 2016.
An Introduction to Java – Part I, language basics
Tonga Institute of Higher Education
Chapter 2 Primitive Data Types and Operations
Presentation transcript:

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Visual Basic Study #1 April 01, 2004 Nam, Sedong Visual Basic Study Group SPARCS ( / KAIST ( 그림 :

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems 세미나 안내 이 세미나는 같이 공부 하는 세미나 – 발표자도 잘 모름, 먼저 조금 봤을 뿐 질문은 바로 바로 – 발표자 말을 끊고서라도 바로 바로 ! – 답변이 길면 끝난 후에

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems 타이포그래피 안내 글자 색 – 중요한 것 – 알아야 할 용어 – 잘 이해가 안 된 것 – 궁금한 것 Code uses this font, Lucida Console 표머리 이것저것표는 이런 색으로 그림 ‘ Source Code are in this box Execution Command are in this box

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems 목차 Same as the Textbook 1.Introduction What Is the Microsoft.NET framework? What Is Visual Basic.NET? An Example Visual Basic.NET Program 2. The Visual Basic.NET Language Source Files Identifiers Keywords Literals Namespaces Symbolic Constants Variables Scope Access Modifiers Assignment Operators and Expressions To be continued

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Introduction VB.NET –Is fully object-oriented –Have full access to the.NET framework –Application run within.NET common language runtime

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems What is the Microsoft.NET Framework? A new way to expose operating system and other APIs –Uniform across all languages (C++, VB, ASP.NET, … ) A new infrastructure for managing application execution –Common Language Runtime (CLR) –Common Type System (CTS) –Common Language Specification (CLS) –Microsoft Intermediate Language (MSIL), JIT A new web server paradigm A new focus on distributed-application architecture –Internet in mind

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems What Is Visual Basic.NET? In brief, better than VB6 (--;) Significant departure from previous generations –VB6 code can ’ t be compiled by the VB.NET compiler –Migration tool (of course, not perfect)

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Hello, World Edit: Editor such as Window ’ s Notepad (Vim) Save: Hello.vb (Any filename ends with.vb) Compile: Execute: Show! Imports System Public Module Hello Public Sub Main Console.WriteLine("hello, world") End Sub End Module vbc Hello.vb Hello.exe

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Hello, World: 첫인상 ( 교재 외 ) ‘ ; ’ 없군 – 줄 단위 파싱 – 한 줄로 해야 할 것을 두 줄에 나누어 쓸 때는 ‘ _ ’ 사용 ‘ { ’ 없네 –End ( Next, Loop, … ) – 인덴테이션은 상관 없음 (Python?) Java 비슷하군 –Imports – 클래스명 첫 문자를 대문자로 ( 하지만 메소드 명까지도 대문자네 )

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Hello, World: The Imports statement Imports –Is merely a convenience –Imports Namespace Same code without Imports: ‘ Imports System Public Module Hello Public Sub Main System.Console.WriteLine("hello, world") End Sub End Module

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Hello, World: The Main Main –1 Main in 1 Application More than 1: compiler option: Main Code in Class: –Shared = Static in Java /main:location Imports System Public Class Hello Public Shared Sub Main Console.WriteLine("hello, world") End Sub End Class

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Source Files All source files:.vb extension The source files of declarations: unimportant

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Identifiers Identifiers: given names to –Namespaces –Types enumerations, structures, classes, standard modules, interfaces, and delegates –Type members Methods, constructors, events, constants, fields, and properties –Variables Characters –First: Alphabetic or “ _ ” –Others: Alphanumeric or “ _ ” –Case insensitive But, case sensitive when called from case-sensitive language

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Keywords Keywords: words with special meaning in a VB.NET KeywordDescription AddHandlerOf Visual Basic.NET Statement AddressOf Visual Basic.NET Statement Alias Used in the Declare statement And Boolean Operator AndAlso Boolean Operator Ansi Used in the Declare Statement Append Used as symbolic constant in the FileOpen function As Used in variable declaration ( Dim, Friend, etc) …

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Literals (1/4) Literals: representation of values Numeric –Integer types Integer (Default, ~ ) Long (~ ) Byte, Short –Floating Point types Single, Double (Default), Decimal x = y * 3.14 xd = y * 3.14D

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Literals (2/4) String –Quotation mark in String Literals: type twice Character –Strings and Characters are distinct types –Next code: compile time error if Option Strict is On : Sonsole.WriteLine(“So then Dave said, “”hello, world””.”) Dim MyChar as Char MyChar = “A”c ‘ Wrong Dim MyChar as Char MyChar = “A”

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Literals (3/4) Date –Format: m/d/yyyy always (regardless of regional setting) Nothing –Nothing : uninitialized value of any type –Numeric: 0 or 0.0, String: “”, … –Reference: null? Dim MyChar as Date MyDate = #11/15/2001 3:00:00 PM#

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Literals (4/4) Summary: All literals Data typeLiteral Boolean True, False CharC Date# DecimalD Double Any floating point or R Integer Any integer (~2,147,483,648) or I Long Any integer (~9,223,372,036,854,775,807, outside of I ) or L ShortS SingleF String“

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Literals: Types (1/2) Fundamental Types –Alias of.NET types –No type-compatibility issues with other languages –Base: Object –Numeric: Short, Integer, Long, Single, Double, Decimal –Others: Byte, Char, String –Byte : no literal representation Dim x As Integer Dim y As System.Int32 If x.GetType() Is y.GetType() Then Console.WriteLine(“They’re the same type.”) End If

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Literals: Types (2/2) Values types and Reference types –Value types All.NET types that derived from System.ValueType Structure and Enum –Reference types Object, String All types declared with Class, Interface, Delegate All.NET types that don ’ t derive from System.ValueType Custom Types –VB.NET provides rich syntax –For both new value types and new reference types

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Literals: Arrays (1/2) Declaration –Array of above example has indexes 0,1,2,3, and 4 Array type –Implicitly inherit from.NET framework ’ s Array type –Have methods: GetLowerBound, … –Upper bound of the array is dynamic Access array elements by the index Initial value of elements: default value of that type Dim a(4) As Integer For i=0 To 4 Console.WriteLine(a(i)) Next

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Literals: Arrays (2/2) Initializing arrays Dynamically allocating arrays Dim a() As String {“First”, “Second”, “Third”} Dim b(,) As Integer {{1,2}, {3,4}, {5,6}} Dim a() As Integer a = New Integer(4) {1, 2, 3, 4, 5} Dim b() As Integer b = New Integer(5) {}

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Literals: Type Conversions (1/3) Two Type Conversions –Widening: Integer to Long,... –Narrowing: Long to Integer,... Possibility of data loss or incorrect result Implicit Narrowing Conversion –When Option Strict On : Compile time error –When Option Strict off : May have Runtime exception Dim a As Integer = 5 Dim b As Long = a

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems 잠깐 : Option Strict Option Strict On –Compiler can help detect coding errors before they become runtime errors Default: Off In Source code When compile ‘ At the top of a source file Option Strict On Vbc MySource.vb /optionstrict+

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Literals: Type Conversions (2/3) Explicit Conversion –May have runtime exception, too Conversion Function CBoolCInt CByteCLng CCharCObj CDateCSng CDblCStr CDec Dim a As Long = 5 Dim b As Integer = CInt(a)

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Literals: Type Conversions (2/3) Object-reference Conversion –Widening: a derived to a base –Narrowing: a base to a derived –Explicit Conversion: CType function

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Namespaces Namespaces: Prevent name (of type) clashes –Thousands of types are defined in the.NET framework Microsoft Recommendation –CompanyName.TechnologyName –Microsoft.VisualBasic Dim X As New FooBarCorp.SuperFoo2100.SomeClass() x.DoSomething() Dim y As new _ MegaBiz.ProductivityTools.WizardMaster.SomeClass() y.DoSomethingElse()

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Namespace: The Namespace statement Specifying a type ’ s namespace A source file may have multiple namespaces Second way: compile time –Root namespace: Concatenation Just a convenience (How about Package in Java?) –To the runtime, a type is NOT “ in ” a namespace –More than one assembly can use a single namespace Vbc src.vb /t:library /rootnamespace:MegaBiz.ProductivityTools.WizardMaster Namespace MegaBiz.ProductivityTools.WizardMaster Public Class SomeClass End Class End Namespace

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Namespace: The Imports statement The CLR deals with type in terms of their full names Offering shortcut If multiple imported namespaces have some name clashes –It ’ s Okay –Use the full name Just a convenience, too –Does NOT set a reference to the assembly Imports System.Drawing Dim pt As Point pt.X = 10 pt.Y = 20

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Symbolic Constants Public Const CarbonHalfLifeInYears As Double = 5730 Public Shared Function RemainingCarbonMass (_ ByVal InitialMass As Double, _ ByVal Years As Long _ ) As Double

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Variables Variable: Identifier declared in a method –Different from Field, Property Dim is short for dimension Type characters: Do NOT use for readability Dim str As String Dim i% Dim d as Double = 10.0 Data typeType character Double# Integer% Long& Single! String$

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Scope Scope: visibility of identifiers VB.NET has block ( End, Loop, Next ) scope –Life of the block-level variable: method Don ’ t count on this behavior: might change in later Dim i As Integer For i=1 to 100 Dim j As Integer For j=1 to 100 ‘... Next ‘j is not visible here

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems Access Modifiers Access Modifiers: for type and type members Public Class SomeClass Public Sub DoSomething() ‘... End Sub Public Sub InternalHelperSub() ‘... End Sub End Class Access ModifierAccessible from FriendThe program in which it is declared PrivateThe context ProtectedThe own class or derived class Protected FriendProtected or Friend PublicAll

S ystem P rogrammers' A ssociation for R esearching C omputer S ystems To be continued 제목 : Visual Basic Study #2 발표 : 김기영 일시 : 다음주 초 내용 2.The Visual Basic.NET Language Assignment Operators and Expressions Statements Classes Interfaces