Visual Basic..

Slides:



Advertisements
Similar presentations
CVEV 118/698 Visual Basic Lecture 1 Prof. Mounir Mabsout Expert 1: Elsa Sulukdjian Expert 2: Walid El Asmar.
Advertisements

5.05 Apply Looping Structures
Instructor: Adil Ibrahim Office: 212 Ullrich Phone: ibrahima 1.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: YangQ 1.
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
CS 2340 Programming in VB.NET Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: YangQ 1.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Tutorial 11 Using and Writing Visual Basic for Applications Code
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Chapter 4: The Selection Process in Visual Basic.
Introduction to Visual Basic.NET Chapter 2 Introduction to Controls, Events.
1 Week 6 The Repetition Structure. 2 The Repetition Structure (Looping) Lesson A Objectives After completing this lesson, you will be able to:  Code.
Tutorial 6 The Repetition Structure
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
CS0004: Introduction to Programming Project 1 – Lessons Learned.
Applications Development
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
CSC 157 (Blum)1 Hello World. CSC 157 (Blum)2 Start/Programs/Microsoft Visual Studio.NET 2003/Microsoft Visual Studio.NET 2003.
Practical Programming COMP153-08S Week 5 Lecture 1: Screen Design Subroutines and Functions.
1 Advanced Computer Programming Lab Calculator Project.
4-1 Chapter 4 The Selection Process in VB.NET. 4-2 Learning Objectives Understand the importance of the selection process in programming. Describe the.
Created by Alia Al-Abdulkarim 2008 Visual Basic Vs. Java.
31/01/ Selection If selection construct.
Using ADO.Net to Build a Login System Dr. Ron Eaglin.
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
Introduction to VB programming Dr. John P. Abraham UTPA Chapters 2 & 3.
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.
Chapter 6 Controlling Program Flow with Looping Structures.
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
Use TryParse to Validate User Input
Dive Into® Visual Basic 2010 Express
Visual Basic Fundamental Concepts
A variable is a name for a value stored in memory.
Chapter 2: The Visual Studio .NET Development Environment
Programming in visual basic .net Visual Basic Building Blocks
Computing with C# and the .NET Framework
Tutorial 10 – Class Average Application Introducing the Do…Loop While and Do…Loop Until Repetition Statements Outline Test-Driving the Class Average.
Apply Procedures to Develop Message, Input, and Dialog Boxes
3.01 Apply Controls Associated With Visual Studio Form
Use TryParse to Validate User Input
Visual programming Chapter 1: Introduction
3.01 Apply Controls Associated With Visual Studio Form
3rd prep. – 2nd Term MOE Book Questions.
Microsoft Access Illustrated
Using Procedures and Exception Handling
User Forms.
Introduction to VB programming
3rd prep. – 2nd Term MOE Book Questions.
CS 2340: Programming in VB Instructor: Dr. Qi Yang Office: 213 Ullrich
Objectives Learn about Function procedures (functions), Sub procedures (subroutines), and modules Review and modify an existing subroutine in an event.
CHAPTER FIVE Decision Structures.
Variables and Arithmetic Operations
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
VISUAL BASIC.
Department Array in Visual Basic
CIS16 Application Development Programming with Visual Basic
Chapter (3) - Looping Questions.
CS285 Introduction - Visual Basic
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Introduction to Programming
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
GUI Programming in Visual Studio .NET
Tutorial 11 Using and Writing Visual Basic for Applications Code
Presentation transcript:

Visual Basic.

Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox from which controls can be selected & placed on form. Features intellisense which prompts for completion of statement or object reference. Provides immediate syntax checking. Provides online debugging, displaying intermediate values. Provides HELP feature.

Toolbox and Controls Label control Textbox control Button Toolbox

Basic Controls Label : Displays information through its Text property. Textbox : Information Entry, Display, and Transfer through its Text Property. Use name of textbox to access information or respond to Gotfocus event. Button : Information Display through its Text Property. Use name of button to respond with subroutine to its Click event.

Event Driven Programming Before event driven programs, typical applications were executed by the computer under control of the application. With event driven programs, the operating system detects user interactions (mouse click, tab key, etc.), passes them to the application, and a control responds by running a subprogram.

Controls and Associated Events Form Load event occurs when form is loaded into computer memory Button Click event occurs when user clicks button with mouse Textbox Lostfocus event occurs when user tabs out of box

Click event for Avg button Private Sub cmdAvg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAvg.Click 'Compute average and store in text property of tbAvg control tbAvg.Text = (CInt(tbNum1.Text) + CInt(tbNum2.Text)) / 2 tbNum1.Select() tbNum1.SelectionStart = 0 tbNum1.SelectionLength = tbNum1.Text.Length tbNum2.Clear() lblStep1.Visible = True lblStep2.Visible = False End Sub

Variables and Data Types Variables are assigned values from a data type VB data types include String, Integer, Double, and Boolean A Dim statement is used to declare a variable and the data type from which its values are assigned

Syntax of Dim and Assignment Statements Dim <variable> as <data-type> Dim avg as double Dim nmbr as integer Dim flag as boolean Assignment <variable> = <expression> avg = (nmbr1 + nmbr2) / 2 flag = false

Variables and Assignment Statements Dim message As String ‘declares string variable 'Assign string constant to messages 1 and 2 ‘Assignment statement : <variable> = <expression> message = "Enter numbers to be “ & _ “averaged in 1st and 2nd textboxes“ lblStep1.Text = message message = "Click Average button" lblStep2.Text = message

Creating a New Project Open Visual Studio 2005 Click Project after Create:

Choosing Project Language, Template, and Project Name Select Visual Basic Windows Windows Application Enter Project Name (Lab1 in example) Click OK

View Startup Form and Set Properties

Problem Analysis & Application Development Analyze Problem Example : Find averages of pairs of numbers, number1 and number2 Input : number1, number2 Process : average = (number1 + number2) / 2 Output : average

Project Implementation & Software Development Design Solution Choose forms and controls Select label – textbox pairs for Input : number1 and number2 and Output : average Select buttons to launch processes Average Write code to implement process Gets number1 and number2 values Computes average = (number1 + number2) /2 Displays average

Select Label Control from Toolbox Click on Form to position Label – drag if desired. Click on Textbox Control from Toolbox Click on Form to position Textbox to right of Label

Name textbox tbNumber1 Holding shift key down, select label and textbox together Copy with Ctrl-C Paste with Ctrl-V (for Number2 entry. Select button Control and position below label – textbox pair Paste again below button for output. Set text properties of labels and the button Name textbox and button controls Write code for button click event – double click on button to generate subroutine shell Label – textbox pair Copy with Ctrl-C

Controls after selection Now set text properties of labels and the button Name textbox and button controls Write code for button click event – double click on button to generate subroutine shell

Controls after setting text properties of labels and the button Name textbox and button controls Name of textbox for output Write code for button click even by double clicking button Button code should Compute & display average Clear input boxes and select first box

Write code for button click event by double clicking button Button code performs following: Computes average Displays average Clears input boxes and selects first box

Test Program in debugger by switching back to design view Click debugger button

Copy Screen to Copy Buffer by doing a Print Screen Paste onto a Word Document Type your name & turn in.

Data types and Statement Types Values Statement Syntax Integer 3, 211, -42, . Declaration Dim <variable> as <datatype> Double 3.17, 1.414 Assignment <variable> = <exp> String “Hello”, “Bob” Selection If <condition> then <statement_list> End if Boolean True, False Repetition For <variable> = <start> to <end> Next

Controls and Associated Events Form Load event occurs when form is loaded into computer memory Button Click event occurs when user clicks button with mouse Textbox Lostfocus event occurs when user tabs out of box Listbox SelectedIndexChanged occurs when user clicks a list item with mouse

Problem Analysis & Application Development Analyze Problem Example : Find average of list of numbers incrementally by Keeping track of number of numbers Keeping track of sum of numbers Computing average after each number Displaying numbers in a listbox

Average of List of Grades

If statement for Control If statement performs an action (<statement_list>) if a condition (<condition>) is true. Syntax : If <Condition> then <statement_list> End if

If statement Example with Else part Syntax with Else If <Condition> then <statement_list1> Else <statement_list2> End if Example : If hours > 40 then overtimeHours = hours – 40 overtimeHours = 0 End If