Programming with Visual Basic.NET. Quick Links Program Code The Code Window The Event Procedure Assignment Statements Using AutoList Radio Buttons Buttons.

Slides:



Advertisements
Similar presentations
VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming.
Advertisements

Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
CA 121 Intro to Programming Tariq Aziz and Kevin Jones GUI Programming in Visual Studio.NET Chapter 1 Tariq Aziz and Kevin Jones.
Compunet Corporation Programming with Visual Studio.NET GUI Week 13 Tariq Aziz and Kevin Jones.
The Initial Visual Basic Screen
Compunet Corporation Programming with Visual Basic.NET GUI Week # 11 Tariq Ibn Aziz.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Chapter 2 –Visual Basic, Controls, and Events
Chapter 3 Introduction to Event Handling and Windows Forms Applications.
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.
05/09/ Introducing Visual Basic Sequence Programming.
Hello World In C++ and Microsoft Visual C++. Directions to begin a project 1. Go to All Programs 2. Open Visual Studio C++ 3. Click on New Project 4.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Chapter 8: Writing Graphical User Interfaces
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Chapter 3 Introducing Visual Basic.NET. 3.1 Visual Basic.NET Windows Programming -Used to create Windows, Web, and Console applications -Uses predefined.
Multiple Forms, Container Controls, AddHandler This presentation is based on the Forms and ContainerControls VB Projects 1.
Chapter 8: Writing Graphical User Interfaces Visual Basic.NET Programming: From Problem Analysis to Program Design.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
Introduction to Visual Basic.NET Chapter 2 Introduction to Controls, Events.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Introduction to Visual Basic.NET Your First Visual Basic.NET Application.
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Introduction It is developed to create software applications. It is a tool for developers of any program that uses both basic and expert settings. It.
Visual Basic.NET BASICS Lesson 5 Exponentiation, Order of Operations, and Error Handling.
Visual Basic.net Textbox & Label Controls. Textbox Naming convention (txt) Primary use (user input) Can except numeric and character values.
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.NET BASICS Lesson 1 A First Look at Microsoft Visual Basic.NET.
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.
What is Visual Basic.NET? 110 B-1 e.g. a word processor doesn’t do anything until the user clicks on a button, types text... A programming language that.
3.2 VB.NET Events An Event Procedure Properties and Event Procedures of the Form Tab Order of Controls Exercises.
3.9 to  Also refer to as Program  Contains set of instructions that tells the computer how to perform specific task.  Each line of code is referred.
1.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 4 Working with Variables, Constants, Data Types, and Expressions.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
COMPUTER PROGRAMMING I 3.02 Apply Properties Associated with the Controls.
Forms and Controls Part 3 dbg --- Naming conventions, Button, Event handlers, Label.
2e – RadioButtons Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
Forms and Controls Part 3 dbg --- Naming conventions, Button, Event handlers, Label.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Visual Basic.Net. Software to Install Visual Studio 2005 Professional Edition (Requires Windows XP Pro) MSDN Library for Visual Studio 2005 Available.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
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.
Visual Basic.NET BASICS Lesson 9 Nested If Statements and Radio Buttons.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
Course ILT Using complex selection structures Unit objectives Include radio buttons and check boxes in an interface, create and call a user- defined Sub.
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”
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Computer Science Up Down Controls, Decisions and Random Numbers.
3.02 APPLY PROPERTIES ASSOCIATED WITH THE CONTROLS Computer Programming I.
Visual Basic.NET Windows Programming
Chapter 1: An Introduction to Visual Basic 2015
3.01 Apply Controls Associated With Visual Studio Form
How to design a Windows Forms application
3.01 Apply Controls Associated With Visual Studio Form
Chapter 2 Visual Basic Interface
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
Building an Application in the Visual Basic .NET Environment
Group Boxes, Radio buttons and Checked List Boxes
CHAPTER FOUR VARIABLES AND CONSTANTS
Presentation transcript:

Programming with Visual Basic.NET

Quick Links Program Code The Code Window The Event Procedure Assignment Statements Using AutoList Radio Buttons Buttons

Programming with Visual Basic.NET An application contains program code which are instructions that tell a computer how to perform a specific task Each line of code is called a statement Most programs you use contain millions of statements and are usually written by teams of programmers VB.NET writes a lot of code for you! This code generates the initial form and sets the default properties of the form. Program Code

Programming with Visual Basic.NET Program Code Cont’d Also, when you draw in a control object in the design window, such as a button, VB.NET generates code automatically to create that object; the code for the object’s functionality is left to you You can get to the code window by using the Solution Explorer Window or by double clicking any object in the form, including the form itself

Programming with Visual Basic.NET The Code Window The code window below shows the code for a blank form Blocks of code can be expanded to show all the statements in the block (+) or collapsed to hide the statements (-)

Programming with Visual Basic.NET The Code Window Cont’d For example, the Windows Form Designer Generated Code is collapsed. If you want to see how much code is generated for you by VB.NET just to create a form, expand this block (click on the plus sign)

Programming with Visual Basic.NET The Event Procedure A procedure is a block of code written to perform a specific task Most control objects require an event procedure, also called event handler The corresponding event procedure is run in response to the event generated by the user Example: When the user clicks a button, the code in the event procedure for that button is run

Programming with Visual Basic.NET Event Procedure Example Below is a program we designed in the Design Window On the left, we have the properties for the ‘Ok’ button; note the Name is btnOK

Programming with Visual Basic.NET Event Procedure Example Now we double-click on the ‘Ok’ button to move from the design window to the code window Now we can add code that will be run when the user clicks on the OK button

Programming with Visual Basic.NET Event Procedure Example An event procedure starts with ( Private ) Sub and ends with End Sub ; what goes between these lines is the body with statements that execute when the event occurs “Sub” is short for subroutine which is another name for procedure

Programming with Visual Basic.NET Good Programming Style Body statements are indented for better readability and to help organize blocks of code There are other rules to follow to have good programming style but we will talk about these in due time

Programming with Visual Basic.NET Assignment Statements Assignment statements are used in a procedure to change a value at run-time You can use assignment to change the value of an object property at runtime  In this case, assignment takes the form: ObjectName.Property = Value ObjectName is the control object name, Property is the property of the object we wish to change, and Value is a valid property setting We’ll do an example…

Programming with Visual Basic.NET Assignment Statements Example The application below has a menu and a label Using the menu, the user can control what is displayed in the label

Programming with Visual Basic.NET Assignment Statements Example How does it work? Let’s first look at the Names of our objects lblHelloWorld mnuInSpanish mnuInEnglish

Programming with Visual Basic.NET Assignment Statements Example Now let’s look at the event procedures for the menu commands, ‘In Spanish’ and ‘In English’ Assignment ObjectName.Property = Value

Programming with Visual Basic.NET Using AutoList In the last example, we saw the following statement:  lblHelloWorld.Text = “Hola Mundo!” If we can’t remember the name of the property we want to change (in this case Text), VB.NET helps us As soon as we type lblHelloWorld. (note the dot), VB.NET recognizes this name and knows it is the name of a label. So it displays a list of properties for a label for you to choose from.

Programming with Visual Basic.NET Using AutoList So, just in case we forgot the name of the property we want to change, the autolist pops up to help us find what we want

Programming with Visual Basic.NET The RadioButton Control We can use a group of radio buttons to allow the user to select one option out of a group In the program below, the user can choose the language using radio buttons and the label will change to that language

Programming with Visual Basic.NET The RadioButton Control The RadioButton control has the properties Name: identifies the control for the programmer. It is good programming style to begin RadioButton object names with rad. Example, radSpanish, radFrench, radEnglish Text: the text that is displayed with the radio button; what the user sees Checked: Can be set to True or False. True means that radio button is selected, False means it is not. Since only one option can be set to True in a group, setting one radio button to True sets all other buttons in the group to false

Programming with Visual Basic.NET Creating RadioButtons A GroupBox object is used to group related radio buttons We first draw a GroupBox on the form and then we add radio buttons to the GroupBox by selecting the RadioButton on the toolbox and clicking in the GroupBox GroupBox has the properties Name (good style to prefix with grp) and Text Then you can double-click each radio button to add assignment statements to change the label text

Programming with Visual Basic.NET Operators and Expressions VB.NET includes built-in operators: addition (+), multiplication (*), division (/), subtraction (-) and exponentiation (^) Operators can be used in conjunction with numbers to form expressions Expressions follow order of operations or operator precedence. You can use brackets to change the order of operation. Example: lblHelloWorld.Text = (5 + 2) * 3 will display 21 in the label; lblHelloWorld.Text = “(5 + 2) * 3” will display (5 + 2) * 3 in the label

Programming with Visual Basic.NET The Button Control Windows applications usually include buttons The button control has the Name (good style to prefix with btn) and Text (appears on the button) properties Double-clicking on a created button allows you to add code to the event procedure for the button; that is, code that will run when the button is clicked