Apply Procedures to Develop Message, Input, and Dialog Boxes

Slides:



Advertisements
Similar presentations
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Advertisements

Chapter 1: An Introduction to Visual Basic.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Example 2.
Input Validation Check the values entered into a text box before beginning any calculations Validation is a form of ‘self-protection’, rejecting bad data.
5.05 Apply Looping Structures
Instructor: Adil Ibrahim Office: 212 Ullrich Phone: ibrahima 1.
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.
Visual Basic Chapter 1 Mr. Wangler.
CS 2340 Programming in VB.NET Instructor: Dr. Qi Yang Office: 213 Ullrich Phone: YangQ 1.
1 Visual Basic for Applications (VBA) for Excel Prof. Yitzchak Rosenthal.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
1 1 Lab1 Ismail M. Romi – IT Dept, PPU, Visual Basic 2005 Programming Tour.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Assignment #1 Advanced Computer Programming.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
COMPUTER PROGRAMMING I Objective 7.03 Apply Built-in Math Class Functions.
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.
Introduction to Visual Basic.NET Your First Visual Basic.NET Application.
11-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
CS0004: Introduction to Programming Project 1 – Lessons Learned.
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.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Visual Basic. The Close Method The Close method is used to close a form. To close a form use the keyword Me to refer to the form. Me.Close()
Graphical User Interface Components Version 1.1. Obectives Students should understand how to use these basic Form components to create a Graphical User.
Introduction to VB programming Dr. John P. Abraham UTPA Chapters 2 & 3.
COMPREHENSIVE Access Tutorial 11 Using and Writing Visual Basic for Applications Code.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
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.
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
1 Displaying Dialog Boxes Kashef Mughal. 2 Midterm Stats Here we go  Average was  Low was 116  High was 184  Mid Quarter Grade - check any.
Use TryParse to Validate User Input
Visual Basic Fundamental Concepts
Chapter 1: An Introduction to Visual Basic .NET
PictureBox, MessageBox, Multiple Forms, Splash Screens and Timers
Visual Basic.NET Windows Programming
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Objective 7.03 Apply Built-in Math Class Functions
Topics Graphical User Interfaces Using the tkinter Module
Chapter 2 – Introduction to the Visual Studio .NET IDE
3.01 Apply Controls Associated With Visual Studio Form
Computer Programming I
Single Dimensional Arrays
Use TryParse to Validate User Input
3.01 Apply Controls Associated With Visual Studio Form
IS 350 Decision-making.
CSI 101 Elements of Computing – Spring 2009
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Introduction to VB programming
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.
Predefined Dialog Boxes
Visual Basic..
CIS16 Application Development Programming with Visual Basic
WEB PROGRAMMING JavaScript.
Part A – Doing Your Own Input Validation with Simple VB Tools
CIS16 Application Development and Programming using Visual Basic.net
Input and Output.
Control Structures Part B - Message and Input Boxes
Multi-Form Applications Things You Need to Know
Additional Topics in VB.NET
Introduction to Programming
Input and Output.
Input and Output Chapter 3.5
GUI Programming in Visual Studio .NET
Tutorial 11 Using and Writing Visual Basic for Applications Code
Presentation transcript:

Apply Procedures to Develop Message, Input, and Dialog Boxes Computer Programming I Summer 2011

Objective/Essential Standard Essential Standard 6.00Apply tools to obtain and validate user input. Indicator 6.02 Apply Procedures to Develop Message, Input, and Dialog Boxes. (4%)

Message, Input, and Windows Forms Message, input and Windows forms increase the interactivity of your application. They allows the user to interface with your application. In this presentation we will look at how to add these new control objects to your application.

The MessageBox Control The MessageBox is a predefined dialog box that displays information to the user. This control was introduced in 5.02. It is covered in more detail here.

The MessageBox Control The following code demonstrates how to use the Show method of the MessageBox class to display a message to the user. Private Sub btnMsgBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMsgBox.Click MessageBox.Show("This is the text in the MessageBox") End Sub You must have the parentheses. You must also have the quotation marks because this is a string.

The MessageBox Control You can display a message box to request information. There are options available with the MessageBoxButtons that allow you to offer to the user more options. MessageBoxButtons.AbortRetryIgnore MessageBoxButtons.OK MessageBoxButtons.OKCancel MessageBoxButtons.RetryCancel MessageBoxButtons.YesNo MessageBoxButtons.YesNoCancel You can compare the user’s choice with the DialogResult.

The MessageBox Control

InputBox Function Computer programming 1

The InputBox Function The input box is a function that allows a user to input information. It displays a prompt in a dialog box, waits for the user to either hit the enter key or click a button, then returns the information from the textbox as a string. Title Prompt

The InputBox Function There is one required parameter, the Prompt. You will need to add a prompt that will be displayed at the top of the dialog box. The Title parameter, while set up with a default of nothing, should be set. The title is displayed in the title bar at the top of the dialog box. Note that there are additional optional parameters. XPos, YPos These set the position where the input box will be displayed.

The InputBox Function This example sets the result of the input box to the string variable strAnswer. Don’t forget that the input box returns a STRING. If you want to turn this value into a numeric value you will need to convert it.

Adding a New Windows Form Computer programming 1

Steps to Add a New Windows Form From the Solution Explorer, right-click on your project, select add, then Windows Form. - or - You can go to the Project menu, select Add Windows Form, then Windows Form. Name the Form (otherwise it will be Form2 if it will be the second form, otherwise it will be Form3, etc). Your new form will be displayed in the Design Window. In the Properties window, Change the FormBorderStyle property to FixedDialog. Set the ControlBox, MinimizeBox, and MaximizeBox to false Customize your form.

Using the New Form You can use the show and hide your new form using the following commands. To show the dialog box formName.Show() To hide the dialog box formName.Hide() To close the dialog box formName.Close()

Try It! Create a new application called msgExample. Save it in the folder as directed by your teacher. Add a Button control Properties: Name: btnShow In your code, do the following Declare a string variable strName Using an input box, ask the user to enter his/her first name. Have that entry go into the variable strName. Using a message box, display the message “Great Job, first name”

Try It! Main form Button Click causes Input box to be displayed (vb only) Gets input from user and assigns it to the variable strName Message box to be displayed. Displays message, including value of the variable from input.

Try It! Solution Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click 'Declare variable for input Dim strName As String 'Get input from user strName = InputBox("Enter your first name", "Input Box Example") 'Display output using a message box. MessageBox.Show("Great Job, " & strName) End Sub

Conclusion This PowerPoint provided an overview of adding a message box, input box and dialog box in Visual Studio. For more information on this topic http://msdn.microsoft.com/en-us/library/2chz8edb(v=VS.80).aspx For more information on dialog boxes http://msdn.microsoft.com/en-us/library/2chz8edb.aspx