Visual Basic 6 Programming.

Slides:



Advertisements
Similar presentations
COMPUTER PROGRAMMING I Essential Standard 5.02 Understand Breakpoint, Watch Window, and Try And Catch to Find Errors.
Advertisements

Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
ALGORITHMS AND FLOWCHARTS
Mathematics for Computing Lecture 4: Algorithms and flowcharts Dr Andrew Purkiss-Trew Cancer Research UK
ECE Application Programming
ITEC113 Algorithms and Programming Techniques
Chapter 8 and 9 Review: Logical Functions and Control Structures Introduction to MATLAB 7 Engineering 161.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Introducing Algorithms, Pseudocode and.
General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009.
Compunet Corporation1 Programming with Visual Basic.NET Selection Structure If-Else Week 4 Tariq Ibn Aziz.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 4 Programming and Software EXCEL and MathCAD.
Programming Lecture #3 CS 101 Autumn 2006 Tariq Jadoon.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
1 Chapter 4 The Fundamentals of VBA, Macros, and Command Bars.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 3 Programming and Software.
CSC141 Introduction to Computer Programming
Flow Charting. Goals Create Algorithms using Flow Charting procedures. Distinguish between Flow Charting and Pseudocode. Top-Down Design Bottom-up Design.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
CSE 131 Computer Science 1 Module 1: (basics of Java)
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
MS Visual Basic Applications Walter Milner. Event-driven programming Standard approach for GUIs Contrast with old character interfaces – program determines.
Visual Basic Programming
Lecture 2 Numerical Methods for Engineering MECN 3500 Department of Mechanical Engineering Inter American University of Puerto Rico Bayamon Campus Dr.
Debugging Visual Basic.NET Programs ► ► Use debugging tools ► ► Set breakpoints and correct mistakes. ► ► Use a Watch and Local window to examine variables.
Introduction to Problem Solving and Control Statements.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
110 F-1 Decisions and Conditions Chapter 4: We can design a form We can calculate To make our programs more powerful, we need to be able to make choices.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
ALGORITHMS AND FLOWCHARTS. A typical programming task can be divided into two phases: Problem solving phase  produce an ordered sequence of steps that.
Visual Basic Declaring Variables Dim x as Integer = 0 In the statement above, x is being declared as an Integer (whole number) and is initialised.
The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Lecture 2 Debugging,
Program design Program Design Process has 2 phases:
A variable is a name for a value stored in memory.
COMPUTATIONAL CONSTRUCTS
Algorithm & Flow Charts Week 1
Programming Languages
REPETITION CONTROL STRUCTURE
ECE Application Programming
UNIT 4 Lesson 13 If statements.
Oracle11g: PL/SQL Programming Chapter 2 Basic PL/SQL Block Structures.
ALGORITHMS AND FLOWCHARTS
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
Computer Programming I
Lecture 2 Introduction to Programming
Introduction to Computer Programming
Chapter 4 – Control Structures Part 1
Programming Fundamentals
Visual Basic 6 Programming.
ALGORITHMS AND FLOWCHARTS
Making Decisions in a Program
ALGORITHMS AND FLOWCHARTS
Visual Basic 6 Programming.
1) C program development 2) Selection structure
ALGORITHMS AND FLOWCHARTS
Visual Basic 6 Programming.
Design and Implementation
Introduction to Algorithms and Programming
` Structured Programming & Flowchart
3. Decision Structures Rocky K. C. Chang 19 September 2018
Microsoft Visual Basic 2005: Reloaded Second Edition
Computer Science Core Concepts
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
Developing a Program.
Basic Concepts of Algorithm
design OO words Debug Variables Data types
Lesson 3. Controlling program flow. Loops. Methods. Arrays.
Presentation transcript:

Visual Basic 6 Programming. Lecture 2 : January 2005 Dr. Andrew Paul Myers 18/11/2018

Logical Variables. To define use : Dim blnTest as Boolean Assignments : blnTest = True blnTest = False Numerically 0 is False, 1 is True. 18/11/2018

Logical Expressions. A logical expression is made up of : Variables. Constants. Logical operators. e.g. some simple test conditions: intRadius = 24 intRadius < > intOld_Radius 18/11/2018

Logical Operators I. Test conditions : < less than. > greater then. < = less than or equal to. > = greater than or equal to. = equal to. < > not equal to. 18/11/2018

Logical Operators II. Logical Test Operators : And Not Or e.g. (intA <= 3) Or (intB >= 5) 18/11/2018

Conditional Statements. Conditions use logical expressions. A simple If statement : If sngX = 1.5 Then sngY = 20.5 If strText < > “Again” Then End 18/11/2018

Block If-Then-Else. If sngZ >= 3.2 Then TextBox1.Text = “3.2 or more” intI = intI + 1 blnTest = True End If If intX = 1 And intY = 2 Then intZ=3 Else intZ=2 18/11/2018

General Form. If <condition(s)> Then <statement(s)> ElseIf <condition(s)> Else <Statement(s)> End If 18/11/2018

Error Trapping. If sngRadius < 0.0 Then TextBox2.Text “Error –ve Radius!” RadiusBox.Text = “” Else sngArea = sngPi * sngRadius^2 Label1.Caption = “Area cm^2 “ TextBox1.Text = sngArea End If 18/11/2018

Case Statement. Select Case intMark Case Is >= 70 TextBox1.Text = “First!” intFirsts = intFirsts + 1 Case Is >= 60 TextBox1.Text = “2.1” intTwoOnes = intTwoOnes + 1 Case Else TextBox1.Text = “2.2 or less.” End Select 18/11/2018

Case : General Form. Select Case <variable> Case Is <condition(s)> <statement(s)> . Case Else End Select 18/11/2018

Intrinsic Functions. Functions return a value of certain data type. Parameters are passed to functions. Parameters can be variables, constants or expressions. Intrinsic means “built in”. dblY=Tan(1#) sngY=Abs(-3.5) sngY=Abs(-3.5*sngX) dblZ=dblX+3.0*Log(dblY) dblY=Val(strRadius) dblY=Log(dblX) strAnswer=Str(sngX) dblY=Sin((dblPi*degrees)/180#) 18/11/2018

See Derived Maths Functions Sheet! More examples… Sin(x) Cos(x) Tan(x) Atn(x) Sqr(x) Abs(x) Is there a Asn(x) Function? NO! Arcsin(X) = Atn(X / Sqr(-X * X + 1)) See Derived Maths Functions Sheet! 18/11/2018

Non maths functions. e.g. Convert string to number. If (IsNumeric(strText_string)) Then sngValue = Val(strText_String) End If e.g. Convert number to string. strText_String = Str(intData1) TextBox1.Text = Str(dblVolume) 18/11/2018

Aids to Program Development. Pseudo Code : “English” like version of program. Flowcharts : Graphical representation of the programs structure. Debugger : Inbuilt tool in VB, allowing users to stop and monitor the program at specified “break points”. 18/11/2018

Pseudo Code I. How to approach writing a program to solve the quadratic equation of the form : The general solution is : 18/11/2018

Pseudo Code II. Start program. Declare and initialise variables. Display a program window with titles and instructions. Do Until program finished. Enter values for a,b,c. If root is complex Then. Calculate complex roots. Else Calculate real roots. End If Display answers. Program finished? Loop. End program. 18/11/2018

Flowcharts I. Symbols : Start or end program : Process for function : Decision : Connector : Start Print Titles End? A 18/11/2018

18/11/2018

VB Debugger. Select options from the “Debug” menu. Set “Breakpoints” to halt the program. Then able to examine variable values, highlight or position cursor over variable to get value. Use “Watch points” to monitor a list of variables as the program runs. Use step options to proceed line by line or enter subroutines. 18/11/2018