VISUAL BASIC 6.0 Designed by Mrinal Kanti Nath.

Slides:



Advertisements
Similar presentations
Working with Intrinsic Controls and ActiveX Controls
Advertisements

VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming.
Visual Basic for Applications. What it does Extends the features and built in functions of Excel – Create and run VB procedures – Some may be easy to.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
CVEV 118/698 Visual Basic Lecture 1 Prof. Mounir Mabsout Expert 1: Elsa Sulukdjian Expert 2: Walid El Asmar.
CSC110 Fall Chapter 5: Decision Visual Basic.NET.
Lec2 P 1 CP2030 Visual Basic For C++ Programmers Copyright © University of Wolverhampton CP2030 VBFC Lecture 2 Back to Index v Basic Data Types v Arithmetic.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 03.
Slide 1 Chapter 2 Visual Basic Interface. Slide 2 Chapter 2 Windows GUI  A GUI is a graphical user interface.  The interface is what appears on the.
Visual Basic Chapter 1 Mr. Wangler.
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module M Programming in Excel with VBA.
1 Visual Basic for Applications (VBA) for Excel Prof. Yitzchak Rosenthal.
An Introduction to Visual Basic
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Introduction to Computational Linguistics Programming I.
Lecture Set 5 Control Structures Part A - Decisions Structures.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
Visual Basic IITG to be expanded. What is Visual Basic? Object Oriented Programming Language (OOP) Graphical User Interface (GUI) Event Driven – Write.
EIW - ASP Introduction1 Active Server Pages VBScript.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
Applications Development
Introduction to Visual Basic Programming. Introduction Simple Program: Printing a Line of Text Another Simple Program: Adding Integers Memory Concepts.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
1 Scripting Languages VBScript - Recognized mainly by Internet Explorer only - Netscape does have a plug-in JavaScript - Recognized by Internet Explorer.
Introduction to Programming Lecture Note - 2 Visual Basic Programming Fundamentals.
CIVIL AND GEOMATIC ENGINEERING FT Okyere. CIV 257- COMPUTER PROGRAMMING Lecture 3.
Introduction to Programming Lecture 2 Msury Mahunnah, Department of Informatics, Tallinn University of Technology.
CECS 5020 Computers in Education Visual Basic Variables and Constants.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
Değişkenler Variables can temporarily store the value of data in memory during the execution of your program. They are often referred to as containers.
CSIT 108 Review Visual Basic.NET Programming: From Problem Analysis to Program Design.
Dive Into® Visual Basic 2010 Express
Visual Basic.NET Windows Programming
Topic 02: Introduction to ActionScript 3.0
Introduction to Programming Lecture 2
A variable is a name for a value stored in memory.
Chapter 2: The Visual Studio .NET Development Environment
VBA - Excel VBA is Visual Basic for Applications
Chapter 1: An Introduction to Visual Basic 2015
Visual Basic Code & No.: CS 218
An Application Uses Variables to Hold Information So It May Be Manipulated, Used to Manipulate Other Information, or Remembered for Later Use.
Visual Basic 6 (VB6) Data Types, And Operators
2.5 Another Java Application: Adding Integers
Variables and Arithmetic Operations
3.01 Apply Controls Associated With Visual Studio Form
1. Introduction to Visual Basic
3.01 Apply Controls Associated With Visual Studio Form
3rd prep. – 2nd Term MOE Book Questions.
Microsoft Access Illustrated
Chapter 2 Visual Basic Interface
Variables and Arithmetic Operations
VISUAL BASIC.
Visual Basic.
Exploring Microsoft Excel
CIS16 Application Development Programming with Visual Basic
WEB PROGRAMMING JavaScript.
T. Jumana Abu Shmais – AOU - Riyadh
Items, Group Boxes, Check Boxes & Radio Buttons
VB.NET PROGRAMMING FINAL EXAM TEST REVIEW.
CS285 Introduction - Visual Basic
Introduction to Problem Solving and Control Statements
Introduction to Programming
Experiment No. (1) - an introduction to MATLAB
Değişkenler Variables can temporarily store the value of data in memory during the execution of your program. They are often referred to as containers.
Presentation transcript:

VISUAL BASIC 6.0 Designed by Mrinal Kanti Nath

INTRODUCTION Visual Basic is an object-oriented programming development system for creating applications that run under any of the Microsoft Windows environments. It has the following two major components: 1. An extensive collection of prewritten tools, called controls. 2. A complete set of program commands, derived from Microsoft’s implementation of the classical Basic programming language. Designed by Mrinal Kanti Nath

EVENT DRIVEN PARADIGM Each feature included within the program is activated only when the user responds to a corresponding object within the user interface. The program’s response to an action taken by the user is referred to as an event. The group of Basic commands that brings about this response is called an event procedure. Designed by Mrinal Kanti Nath

OBJECT RELATED CONCEPTS FORMS: In VB, a window is called a form. Each form includes a title bar at the top & it also include a menu bar, a status bar, one or more toolbars, slide bars, etc. CONTROLS: The icons with which the user interacts are called controls. Commonly used controls include command buttons, option buttons, check boxes, labels, text boxes, picture boxes and menus. OBJECTS: Forms and controls are referred to collectively as objects. Designed by Mrinal Kanti Nath

OBJECT RELATED CONCEPTS CONTD.. PROPERTIES: Objects include properties that generally define their appearance or behavior. For example, the name, caption, height, width, background color, location etc.. METHODS: Some objects also include special program statements called methods. For example, show is a method that can be used with a hidden form to make it visible. Designed by Mrinal Kanti Nath

VB PROGRAM COMPONENTS In VB, a program is referred to as a project. Every VB project consists of at least two separate files – a project file (.vbp) and a form file (.frm) Some projects include multiple form files and other types of files, such as class module (.cls) files, standard module (bas) files, resource (.res) files, and ActiveX control (.ocx) files. Designed by Mrinal Kanti Nath

Designed by Mrinal Kanti Nath

Designed by Mrinal Kanti Nath

Designed by Mrinal Kanti Nath

Code Editor Window Designed by Mrinal Kanti Nath

Example: Area of a Circle Designed by Mrinal Kanti Nath

Example: Area of a Circle Contd.. Designed by Mrinal Kanti Nath

Example: Area of a Circle Contd.. Designed by Mrinal Kanti Nath

Example: Area of a Circle Contd.. Designed by Mrinal Kanti Nath

Example: Area of a Circle Contd.. Designed by Mrinal Kanti Nath

Example: Area of a Circle Contd.. Designed by Mrinal Kanti Nath

Example: Area of a Circle Contd.. Designed by Mrinal Kanti Nath

Example: Area of a Circle Contd.. Designed by Mrinal Kanti Nath

Data Types and Data Declaration Integer Long (Long Integer) Single Double String E.G.- Dim variable name As data type Dim Area As Single Dim StudentName As String Designed by Mrinal Kanti Nath

Const TaxRate As Single = 0.28 Named Constant Similar to variables. But, variables can be reassigned different values within a program, whereas named constants remain unchanged throughout a program. E.g.- Const TaxRate As Single = 0.28 Designed by Mrinal Kanti Nath

User Defined Data Types Type Customer CustomerName As String AcctNo As Integer Balance As Single End Type Once the data type has been defined, we can declare one or more variables of this data type, as follows. Dim OldCustomer As Customer, NewCustomer As Customer Designed by Mrinal Kanti Nath

Arithmetic Operators The standard arithmetic operators are Addition: + (plus sign) Subtraction: − (minus sign) Multiplication: * (asterisk) Division: / (slash) Exponentiation: ^ (caret, or upward-pointing arrow) Integer division: \ (backward slash) Integer remainder: Mod Designed by Mrinal Kanti Nath

Relational Operators Equal: = Not equal: <> Less than: < Less than or equal to: <= Greater than: > Greater than or equal to: >= Designed by Mrinal Kanti Nath

Logical Operators And will result in a condition that is true if both expressions are true. Or will result in a condition that is true if either expression is true, or if they are both true Xor will result in a condition that is true only if one of the expressions is true and the other is false. Not is used to reverse (negate) the value of a logical expression. Eqv will result in a condition that is true if both expressions have the same logical value Imp will always result in a true condition unless the first expression is true and the second is false. Designed by Mrinal Kanti Nath

Hierarchy Of Operations Exponentiation ^ Negation (i.e., preceding a numeric −quantity with a minus sign) Multiplication and division * / Integer division \ Integer remainder Mod Addition and subtraction + − Relationals = <> < <= > >= Logical Not Not Logical And And Logical Or Or Logical Xor Xor Logical Eqv Eqv Logical Imp Imp Designed by Mrinal Kanti Nath

Inserting Parentheses [ 2(a + b)2 + (3c)2 ] m / (n+1) A Visual Basic expression corresponding to this algebraic term is (2 * (a + b) ^ 2 + (3 * c) ^ 2) ^ (m / (n + 1)) ((2 * ((a + b) ^ 2)) + ((3 * c) ^ 2)) ^ (m / (n + 1)) Both are correct. The arithmetic expression −x ^ n is equivalent to −(x ^ n) or −1 * (x ^ n) Designed by Mrinal Kanti Nath

String Concatenation Str1 = "TEN" Str2 = "THOUSAND” Str1 & " " & str2 & " DOLLARS” Str1 + " " + str2 + " DOLLARS” Both will print: TEN THOUSAND DOLLARS Designed by Mrinal Kanti Nath

Designed by Mrinal Kanti Nath

Print Statement Print statement is used to display information within the currently active form, beginning in the upper left corner. Dim Student As String, X As Integer, C1 As Single, C2 As Single . . . . . Student = "Aaron" X = 39 C1 = 7 C2 = 11 Print "Name:", Student, X, (C1 + C2) / 2 Designed by Mrinal Kanti Nath

If-Then Syntax: If logical expression Then executable statement End If Example: If income <= 14000 Then tax = 0.2 * pay net = pay - tax Designed by Mrinal Kanti Nath

If-Then-Else Syatax: If logical expression Then executable statements End If Example: If (status = "single") Then tax = 0.2 * pay tax = 0.14 * pay Designed by Mrinal Kanti Nath

If-Then-Else If logical expression 1 Then executable statements ElseIf logical expression 2 Then repeated ElseIf clauses . . . . . . . Else End If Designed by Mrinal Kanti Nath

Case structure Syntax Select Case expression Case value1 executable statements Case value2 . . . . . . . . Case Else End Select Designed by Mrinal Kanti Nath

Case Structure Example Dim x, z, n As Integer Select Case n Case 1 z = x Case 2 z = x ^ 2 Case 3 z = x ^ 3 Case Else MsgBox("ERROR - Please try again") End Select Designed by Mrinal Kanti Nath

For- Next Syntax For index = value1 To value2 executable statements Next index Example: sum = 0 For i = 1 To 10 sum = sum + i Next i Designed by Mrinal Kanti Nath

For- Next Contd.. For index = value1 To value2 Step value3 executable statements Next index sum = 0 For count = 2.5 To -1 Step -0.5 sum = sum + count Next count count will take on the values 2.5, 2.0, 1.5, . . ., 0.0, -0.5, -1.0. Hence, the final value of sum will be 6.0 (because 2.5 + 2.0 + 1.5 + 1.0 + 0.5 + 0.0 – 0.5 – 1.0 = 6.0). Designed by Mrinal Kanti Nath

Do Loop First form: Do While logical expression executable statements Second form: Do Until logical expression Designed by Mrinal Kanti Nath

Do Loop Contd.. Third form: Do executable statements Loop While logical expression Fourth form: Loop Until logical expression Designed by Mrinal Kanti Nath

Do Loop Contd.. First form continues to loop as long as the logical expression is true Second form continues to loop as long as the logical expression is not true (until the logical expression becomes true). Third form continues to loop as long as the logical expression is true. Fourth form continues to loop as long as the logical expression is not true. Designed by Mrinal Kanti Nath

While-Wend While logical expression executable statements Wend Example: sum = 0 count = 1 While count <= 10 sum = sum + count count = count + 1 Designed by Mrinal Kanti Nath

Stop Statement Used to terminate the execution at any point in the program. The statement consists simply of the keyword Stop May appear anywhere in a Visual Basic program except at the very end. Multiple Stop statements may appear in the same program, as dictated by the program logic. Designed by Mrinal Kanti Nath

Designed by Mrinal Kanti Nath

Designed by Mrinal Kanti Nath

Thank You Designed by Mrinal Kanti Nath