Bit (0, 1) Byte (8 bits: 0-255) Numeral systems. Binary (bin) 0,1 Decimal (dec) 0, 1, 2, 3, Hexadecimal (hex) 0, 1, 2, 3, 1/13/2011

Similar documents
Chapter 2: Using Data

Programming Language 2 (PL2)

Microsoft Visual Basic 2005: Reloaded

Visual C# Instructor s Manual Table of Contents

Understand Computer Storage and Data Types

Unit 4. Lesson 4.1. Managing Data. Data types. Introduction. Data type. Visual Basic 2008 Data types

Tokens, Expressions and Control Structures

Darshan Institute of Engineering & Technology for Diploma Studies

6.096 Introduction to C++ January (IAP) 2009

Agenda & Reading. VB.NET Programming. Data Types. COMPSCI 280 S1 Applications Programming. Programming Fundamentals

Introduction to C# Applications

Programming in C++ 4. The lexical basis of C++

.Net Technologies. Components of.net Framework

SKILL AREA 306: DEVELOP AND IMPLEMENT COMPUTER PROGRAMS

Lesson 02 Working with Data Types. MIT 31043: VISUAL PROGRAMMING By: S. Sabraz Nawaz Senior Lecturer in MIT

Program Fundamentals

VARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals

Introduce C# as Object Oriented programming language. Explain, tokens,

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.

INTRODUCTION 1 AND REVIEW

Lesson 02 Working with Data Types MIT 31043, Visual Programming By: S. Sabraz Nawaz

Appendix G: Writing Managed C++ Code for the.net Framework

Chapter 1 Getting Started

Advanced Computer Programming

BASIC ELEMENTS OF A COMPUTER PROGRAM

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

Index. object lifetimes, and ownership, use after change by an alias errors, use after drop errors, BTreeMap, 309

C# Fundamentals. Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh

Basic Types, Variables, Literals, Constants

Lecture Notes on Programming Languages

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

Types, Operators and Expressions

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

C#: framework overview and in-the-small features

C# Types. Industrial Programming. Value Types. Signed and Unsigned. Lecture 3: C# Fundamentals

Outline. Data and Operations. Data Types. Integral Types

Industrial Programming

C# MOCK TEST C# MOCK TEST I

UNIT 2 USING VB TO EXPAND OUR KNOWLEDGE OF PROGRAMMING

QUIZ. 1. Explain the meaning of the angle brackets in the declaration of v below:

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Microsoft Visual Basic 2015: Reloaded

C++ Programming: From Problem Analysis to Program Design, Third Edition

Lecture 03 Bits, Bytes and Data Types

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Language Fundamentals

Unit 3. Constants and Expressions

EMBEDDED SYSTEMS PROGRAMMING Language Basics

Murach s Visual Basic 2012, C4 2013, Mike Murach & Associates, Inc. Slide 1. The built-in value types (continued)

Module 4: Data Types and Variables

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Variables. Data Types.

Variables and Constants

Integer Data Types. Data Type. Data Types. int, short int, long int

Types, Operators and Expressions

PROGRAMMING IN C++ COURSE CONTENT

Question And Answer.

TYPES, VALUES AND DECLARATIONS

Short Notes of CS201

Creating a C++ Program

Introduction to Programming Using Java (98-388)

The C++ Language. Arizona State University 1

C#.Net. Course Contents. Course contents VT BizTalk. No exam, but laborations

CS201 - Introduction to Programming Glossary By

CS313D: ADVANCED PROGRAMMING LANGUAGE

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a) and (b) D. stands for Graphic Use Interaction

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

10/9/2012. Computers are machines that process data. assignment in C# Primitive Data Types. Creating and Running Your First C# Program

Data Types Literals, Variables & Constants

CIS 3260 Intro to Programming with C#

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017

Fundamental of C programming. - Ompal Singh

File Handling in C. EECS 2031 Fall October 27, 2014

Special Topics for Embedded Programming

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018

Programming (1.0hour)

ME240 Computation for Mechanical Engineering. Lecture 4. C++ Data Types

CHAPTER 3: FUNDAMENTAL OF SOFTWARE ENGINEERING FOR GAMES.

CPSC 3740 Programming Languages University of Lethbridge. Data Types

DAD Lab. 1 Introduc7on to C#

Java Notes. 10th ICSE. Saravanan Ganesh

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

A Comparison of Visual Basic.NET and C#

Chapter-8 DATA TYPES. Introduction. Variable:

Data Types Literals, Variables & Constants

CS112 Lecture: Variables, Expressions, Computation, Constants, Numeric Input-Output

Zheng-Liang Lu Java Programming 45 / 79

Brief introduction about memory queue -- CUQueue and CScopeUQueue objects

Excel VBA Variables, Data Types & Constant

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

(the bubble footer is automatically inserted in this space)

CHAPTER 5 VARIABLES AND OTHER BASIC ELEMENTS IN JAVA PROGRAMS

Datatypes, Variables, and Operations

Variables and numeric types

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

Full file at

Transcription:

* VB.NET Syntax I 1. Elements of code 2. Declaration and statements 3. Naming convention 4. Types and user defined types 5. Enumerations and variables Bit (0, 1) Byte (8 bits: 0-255) Numeral systems Binary (bin) 0,1 Decimal (dec) 0, 1, 2, 3, Hexadecimal (hex) 0, 1, 2, 3, 1

Structure Modules, methods (procedures), lines of code (OOP) Classes, properties, methods, events, lines of code Syntax Rules for combining the language elements Elements Statements, declarations, methods, operators, keywords Dim a, b As Integer, c As Integer Dim d As Integer, e As Boolean a = 3 a is 3 b = 2 + 5 b is 7 c = a + b c is 10 d = d + 1 d was 0 and now is 1 e = Not e e was false and now is true If a > b Then c = 3 MsgBox("Value of C is " & c) 2

A set of procedures (subroutines or functions) The part of VB.NET that s not OOP A set of properties, methods, or events Properties: object's attributes Methods: object s actions Events: object s responses to events 3

A self-contained block of code that does something (aka procedure) Breaks up a program into manageable modules Promotes code reuse Some methods have input parameters, some have return values (i.e., functions) and some don t (i.e., subroutines) 4

Statements Declarations (of variables, objects, arrays, etc) Keywords Methods Operators Memory address Pointer to address Name of pointer 5

When Option Explicit is on, VB requires a declaration of a variable or an object before it can be used (Don t turn Option Explicit off!). Option Explicit On Dim numberofstudents As Integer Dim coursenumber As String = GEOG490 initializer Dim a, b, c As Double, d As Integer Dim penvelopea As IEnvelope penvelopea = New CType(pActiveView.Extent, IEnvelope) Dim penvelopeb As New IEnvelope = penvelopeb Dim anobject As Object Visual Basic type CLR type Nominal storage allocation Value range Boolean Boolean Platform dependent True or False Byte Byte 1 byte 0 through 255 (unsigned) Char(single character) Char 2 bytes 0 through 65535 (unsigned) Date DateTime 8 bytes 0:00:00 (midnight) on January 1, 0001 through 11:59:59 PM on December 31, 9999 Decimal Decimal 16 bytes 0 through +/-79,228,162,514,264,337,593,543,950,335 (+/- 7.9...E+28) with no decimal point; 0 through +/- 7.9228162514264337593543950335 with 28 places to the right of the decimal; smallest nonzero number is +/- 0.0000000000000000000000000001 (+/-1E-28) Double(doubleprecision floatingpoint) Double 8 bytes -1.79769313486231570E+308 through -4.94065645841246544E- 324 for negative values; 4.94065645841246544E-324 through 1.79769313486231570E+308 for positive values Integer Int32 4 bytes -2,147,483,648 through 2,147,483,647 (signed) Long(long integer) Int64 8 bytes -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807 (9.2...E+18 )(signed) Object Object(class) 4 bytes on 32-bit platform Any type can be stored in a variable of type Object 8 bytes on 64-bit platform SByte SByte 1 byte -128 through 127 (signed) Short(short integer) Int16 2 bytes -32,768 through 32,767 (signed) Single(single-precision -3.4028235E+38 through -1.401298E-45 Single 4 bytes for negative values; floating-point) 1.401298E-45 through 3.4028235E+38 for positive values String(variable-length) String(class) Platform dependent 0 to approximately 2 billion Unicode characters UInteger UInt32 4 bytes 0 through 4,294,967,295 (unsigned) ULong UInt64 8 bytes 0 through 18,446,744,073,709,551,615 (1.8...E+19 )(unsigned) User-Defined (inherits from Each member of the structure has a range determined by its data Platform dependent (structure) ValueType) type and independent of the ranges of the other members UShort UInt16 2 bytes 0 through 65,535 (unsigned) 6

Option Explicit prevents confusion in code or incorrect typing a = 5 Option Strict prevents narrowing conversion Dim a As Integer a = 1.25 Scope Description Declaration Block Available only within the code block in which it is declared Dim Procedure Available to all code within the procedure in which it is declared Dim Module/ Class Namespace (project) Available to all code within the module, class, or structure in which it is declared Available to all code in the namespace (project) in which it is declared Public/ Private Friend 7

Public, Private - module/class level Public maximumallowed As Double Private salary As Decimal Protected -class level only Protected currentusername As String Friend -namespace/assembly level (cannot be used in procedures) Friend projectname As String 8

Specifies that one or more declared local variables are to remain in existence and retain their latest values after termination of the procedure in which they are declared. Function updatesales(byval thissale _ As Decimal) As Decimal Static totalsales As Decimal = 0 totalsales += thissale Return totalsales End Function Declares and defines one or more constants Const can be used only at module or procedure level Const maximum As Long = 459 Public Const helpstring As String = "HELP" Private Const startvalue As Integer = 5 9

Enumerations offer an easy way to work with sets of related constants and to associate constant values with names Member name [= initializer] With integer initializer 10

Enum.GetNames and Enum.GetValues methods Enumerations make for clearer and more readable code, particularly when meaningful names are used. Benefits : Reduces errors caused by transposing or mistyping numbers Makes it easy to change values in the future Makes code easier to read, which means it is less likely that errors will creep into it Ensures forward compatibility 11

See http://msdn.microsoft.com/en-us/library/t904x0th(vs.80).aspx Declared element Namespace Module/Class Procedure Variable (Dim Statement) Constant (Const Statement) Enumeration (Enum Statement) Not allowed Not allowed Friend Private (Public in Structure) Private (Public in Structure) Public Public Public Not allowed 12

VB.NET is NOT case sensitive, however Names A list of identifiers concatenated to form a name Pascal case ErrorLevel Camel case totalnetworkdistance Uppercase System.IO Be consistent! Don t use reserved terms (e.g., Double, False) Use Pascal casing for namespaces, classes, members, methods, and constants Const MapUnits As String = meters Use Camel casing for variables and parameters Dim isvisible As Boolean Do not use underscores, hyphens, or any other nonalphanumeric characters 13

Dim lastname As String lastname = brown Msgbox(lastName.ToUpper) return BROWN Msgbox(String.Compare(lastName.ToUpper, _ WHITE ) return -1 Msgbox(String.Compare(lastName.ToUpper, _ BROWN ) return 0 14

Public Structure SystemInfo Public CPU As String Public Memory As Long Public PurchaseDate As Date End Structure Public Class Class1 Public Function MyFunction Dim MySystem, YourSystem As SystemInfo MySystem.CPU = "486" Dim TooOld As Boolean If YourSystem.PurchaseDate < #1/1/1992# Then TooOld = True YourSystem = MySystem End Function End Class Array Arraylist(queue and stack) Hashtable Binary (search) tree Graph 15