Chapter-1 Introduction to Visual Basic GUI- A GUI is a graphical (rather than purely textual) user interface to a computer. The term came into existence.

Slides:



Advertisements
Similar presentations
Integrated Business Applications with Databases (D3) Jenny Pedler
Advertisements

Working with Intrinsic Controls and ActiveX Controls
Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Programming in Visual Basic
Chapter 1 Introduction to Visual Basic.NET Programming In Visual Basic.NET © 2001 by The McGraw-Hill Companies, Inc. All rights reserved.
CVEV 118/698 Visual Basic Lecture 1 Prof. Mounir Mabsout Expert 1: Elsa Sulukdjian Expert 2: Walid El Asmar.
Chapter 1 Introduction to Visual Basic 2010 Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
 Visual Basic is an object-oriented language used to write application programs that run in Windows or on the Internet using a graphical user interface.
Copyright © 2001 by Wiley. All rights reserved. Chapter 3: Variables, Assignment Statements, and Arithmetic Variables Assignment Statements Arithmetic.
Visual Basic Chapter 1 Mr. Wangler.
Variables and Constants
CS0004: Introduction to Programming Variables – Numbers.
Microsoft Visual Basic 2005: Reloaded Second Edition
Creating Macros Using VBA. Assigning a Macro to a Button Display the Forms toolbar. Click the Button icon. Click and drag the mouse pointer to specify.
Chapter 1 P. 1 Writing Windows applications with Visual Basic Figure 1.1 The first program works as follows: (These operations can be performed in any.
An Introduction to Visual Basic
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
National Diploma Unit 4 Introduction to Software Development Data types, variables and constants.
Introduction to Visual Basic.NET Programming In Visual Basic.NET.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Java Programming, Second Edition Chapter One Creating Your First Java Program.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Outline Software and Programming Program Structure Tools for Designing Software Programming Languages Introduction to Visual Basic (VBA)
Chapter 2: Using Data.
CPS120: Introduction to Computer Science
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Fundamentals of GUI Programming. Objectives: At the end of the session, you should be able to: describe the guidelines that are used for creating user-friendly.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Applications Development
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
Introduction to Visual Basic Programming. Introduction Simple Program: Printing a Line of Text Another Simple Program: Adding Integers Memory Concepts.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM)
CPS120: Introduction to Computer Science Variables and Constants.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
Chapter 1 Introduction to Visual Basic.NET Programming In Visual Basic.NET © 2001 by The McGraw-Hill Companies, Inc. All rights reserved.
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Introduction to Visual Basic 2008 Chapter 1.
Introduction to Programming Python Lab 3: Arithmetic 22 January PythonLab3 lecture slides.ppt Ping Brennan
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.
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Chapter 1: Introduction to Computers and Programming.
Making Interactive Programs with Visual Basic .NET
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are used in programs so that values can be represented with.
© 2006 Lawrenceville Press Slide 1 Chapter 4 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
Visual Basic.NET Windows Programming
Fundamentals of Programming I Overview of Programming
Egyptian Language School Computer Department
A variable is a name for a value stored in memory.
VBA - Excel VBA is Visual Basic for Applications
Visual Basic Variables
1. Introduction to Visual Basic
CIS16 Application Development Programming with Visual Basic
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
CS285 Introduction - Visual Basic
Introduction to Programming
Visual Basic Numbers Chapter 3.3 Prepared By: Deborah 7/9/2019.
Presentation transcript:

Chapter-1 Introduction to Visual Basic GUI- A GUI is a graphical (rather than purely textual) user interface to a computer. The term came into existence because the first interactive user interfaces to computers were not graphical; they were text-and-keyboard oriented and usually consisted of commands you had to remember. The command interface of the DOS operating system (which you can still get to from your Windows operating system) is an example of the typical user- computer interface (character/command user interface-CUI) before GUIs arrived. An intermediate step in user interfaces between the command line interface and the GUI was the non-graphical menu-based interface, which let you interact by using a mouse rather than by having to type in keyboard commands. Today's major operating systems provide a graphical user interface. Applications typically use the elements of the GUI that come with the operating system and add their own graphical user interface elements and ideas.

Programming languages- There are various types of programming languages, each was developed to solve a particular kind of problems. 1. Procedural languages- A computer programming language that follows, in order, a set of commands. Examples of computer procedural languages are BASIC, C, FORTRAN, and Pascal. 2. Object Oriented programming language- A type of programming in which programmers define not only the data type of a data structure, but also the types of operations (functions) that can be applied to the data structure. In this way, the data structure becomes an object that includes both data and functions. In addition, programmers can create relationships between one object and another. For example, objects can inherit characteristics from other objects.

3. Event Driven programming language- In computer programming, event-driven programming also known as event-based programming is a programming method in which the flow of the program is determined by user actions such as mouse clicks, key presses.

VB Environment- VB is event-driven programming language, which has some of the features of object oriented programming language. In VB you will work with objects, which has properties and methods. Objects- Object is an element from a VB program, such as a control, form or code module that holds programming statement. Properties- A Property helps to differentiate a control from other control because the property shows appearance and behavior of a control. Properties have values such as colors, names, size and location on the form. Methods- Actions associated with the objects are called methods. Some common methods are move, print, show etc. Event- Each action by the user causes an event, Event is an activity that occurs during program execution, such as mouse click, key-press, activate etc.

VB Environment- An integrated development environment (IDE) is a programming environment that has been packaged as an application program, typically consisting of a code editor, a compiler, a debugger, and a graphical user interface (GUI) builder. Main Window- Title bar, Menu bar & tool bar Tool Box Form Window Project Explorer Properties window Form Layout window

Visual Basic Projects- The Project file with extension.vbp Each form in project saved with extension.frm Optionally you can have.bas files that contains basic statement accessed from any form of the project. (These files are also called standard code module) If you include additional controls which are not part of standard control set then the.ocx file names will be included in your project. After you save a project, VB automatically adds one or more files to your project with extension.vbw(VB project workplace). This file holds information about each of your project’s form.

Errors in VB- 1. Compile time errors- (Occurs when you press enter key or when you execute code) Project code->m/c code=>Compile time errors if you break syntax rule Ex. if a<b ‘if without then gives compile time error print a else print b end if If you spelled wrong ennd ‘ennd instead End

Run Time Errors- If your project halts during execution then it’s runtime error Common runtime errors- Divide by zero Divide by zero Performing an arithmetic operation on nonnumeric data Performing an arithmetic operation on nonnumeric data Find a square root of negative number Find a square root of negative number Illegal use of object Illegal use of object Logical Error- ?

Naming rules and conventions for objects – Rules- Begin with a letter 40 char long Letter, digit and underscores Conventions-Follow this to make project more understandable Always begin a name with a lowercase three-letter prefix and capitalize the first character after the prefix. EX- cmdShow, lblMessage, optColor For name with multiple word,capitalize first letter of each word frmDataEntry, chkPrintForm

Visual Basic Statements- Remark statement-To add comments,Use apostrophe to start comment. Assignment Statement-Assign value to variable or value to property. End Statement-Stops execution of program

Project Execution and debugging- Execution- F5 F5 Start Start Start with full compilation Start with full compilation Debugging-F8 Debugging-F8

Variables & Constant Variables- Memory location that holds the data that can be changed during program execution is called Variable. Constant Memory location that holds the data that can not changed during program execution is called Constant. Identifier When you declare a variable VB reserves memory space & assigns a name called identifier.

Naming Rules & conventions for Variable & Constant- Rules- 1 to 255 chars long Combination of digits, alphabets & underscores They may not be reserved words Conventions- Must be meaningful Choose a name that indicates purpose of variable/constant Use prefix before name Capitalize First name of the word Ex- intEmpNum dtm B_Date dblPer

Data types in VB Boolean 2 bytesTrue/False Byte 1 byte0 to 255 Currency8 bytesDecimal fractions (dollars,Rs.) Date8 bytesmm/dd/yyyy Double ----”---- floating point number Integer 2 bytes whole numbers ( to 32767) Long 4 bytes Long whole numbers Single 4 bytesfloating point with 6 digits accuracy String fixed or variables 1 to chrs Variant 22 bytes Converts data according to value.

Examples- Dim s as string*3 S=“VBProgramming” Print s Output-VBP Dim s as variant S=10 Print s=10 S=“hello” Print s

Variable declaration- Dim identifier as [type] Dim-Dimensions (size) Type is optional if omitted default is variant

OperatorExampleDescription +A+BAdd two values -A-100Subtract second val from first *Total*FactMultiply two values /Tax/aDivide one no by other ModNum1 Mod Num2Divide 2 nos and return only remainder ^No1 ^ PowRaises a value to a power & or +Name1 & Name2Concatenates 2 strings OPERATORS : Arithmetic Operators :

Operator Example Description +A+B Add two values -A-400 Subtract one value from other * Total*fact Multiply two values. /Tax/a Divide one number by another number Mod Num1 mod num2 Divides two nos. and return only remainder. ^Num^expRaises a value to a power

Comparison Operators :, =,<> Used to compare expressions Example : This example shows various uses of comparison operators, which you use to compare expressions. Dim MyResult MyResult = (45<35) 'Returns False. MyResult = (45=45)'Returns True. MyResult = (4 <> 3) 'Returns True. Like Operator : Syntax- “string” like “pattern” Dim MyCheck MyCheck = "aBBa" Like "a*a"'Returns True. MyCheck = "F" Like "[A-Z]"'Returns True. MyCheack = "CAT123khg" Like "B?T*" 'Returns False.

Case statement Syntax- Select Case VARIABLE Case expression1 : Case expression2: [Case else: ] End select *Expression can be any numeric or string value

Select statement can handle a single value, ranges and sets Example-Select case with single value- Write a program to add, sub, div and multiply 2 numbers using case statement. Dim a As Integer, b As Integer, ope As String a = Val(Text1) b = Val(Text2) ope = Text3 Select Case ope Case "+": Print a + b Case "-": Print a - b Case "*": Print a * b Case "/": Print a / b Case Else: Print "Wrong selection" End Select

Example- Select case with Sets and range of values WAP to print given letter is an alphabet, a number or a symbol Dim a As String a = Text1 Select Case a Case 0 To 9: Print "Numbers" Case "A" To "Z", "a" To "z": Print "Alpahabets" Case Else: Print "Symbol" End Select

Example- Select case with Relational Operator WAP to print grade for given percentage Dim per As Integer per = Val(Text1) Select Case per Case Is < 40: Print "FAIL" Case Is < 60: Print "PASS" Case Is < 70: Print "First" Case Is > 70: Print "DIST" End Select