Input Dialog Box An input dialog box can be used to obtain a single item of input from the user Presents a window (dialog box) requesting input Syntax:

Slides:



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

VB Numbers and Strings School of Business Eastern Illinois University (Week 4, Monday 2/03/2003) © Abdou Illia, Spring 2003.
The Print Formatting Statement … named printf. 2 Introduction to printf statements print and println statements don’t allow us to easily format output.
Fundamentals of Programming in Visual Basic
VB Built-in Functions School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 5, Monday 2/10/03)
Built-In Functions.
Introduction to Computing Dr. Nadeem A Khan. Lecture 11.
Chapter 7. 2 Objectives You should be able to describe: The string Class Character Manipulation Methods Exception Handling Input Data Validation Namespaces.
Fundamentals of Programming in Visual Basic
On to… string operations & functions. Concatenation (&) §When we want to combine two character strings into one new (longer) string, we can concatenate.
Section 3.6 BUILT-IN FUNCTIONS involving numbers & strings.
Chapter 31 Fundamentals of Programming in Visual Basic (Continue VI) String Properties and Methods: "Visual".Length is 6. "Visual".ToUpper is VISUAL. "123.
Programming Practice in Visual Basic The Initial Visual Basic Screen Toolbox Project Explorer window Properties window Form Menu bar Description pane.
Fundamentals of Programming in Visual Basic
Input/Output  Input/Output operations are performed using input/output functions  Common input/output functions are provided as part of C’s standard.
Input/Output CE 311 K - Introduction to Computer Methods Daene C. McKinney.
Database Management Review for Final (Part 1) School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 15, Wednesday 4/30/2003)
CS0004: Introduction to Programming Input and Output.
Intrinsic Functions Pre-coded Functions Used to improve developer productivity Broad Range of Activities Math calculations Time/Date functions String.
Chapter 3 Elements of Assembly Language. 3.1 Assembly Language Statements.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Microsoft Office Excel Copyright © 2008 Pearson Prentice Hall. All rights reserved
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Chapter 2 Overview of C Part I J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
Chapter 3 - VB.NET by Schneider1 Chapter 3 – Fundamentals of Programming in VB.NET VB.NET Controls VB.NET Events Numbers Strings Input and Output.
1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Chapter 3 - VB 2008 by Schneider1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Microsoft Visual Basic 2005 BASICS Lesson 4 Mathematical Operators.
Using Classes BCIS 3680 Enterprise Programming. Overview 2  Using Classes  Using premade classes for input and output  Display output: System, JOptionPane.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Input, Output, and Processing
Input Textboxes Input Boxes Different than textboxes Good for small amount of input (form full of textboxes is not nice) X = Inputbox(“prompt message”,
Input and Output. Announcements  Exam Next Wednesday –Next Monday: Review session.  Invited talk: –7:30 PM,Tuesday, Oct 28th. –Prof. Katherine Socha.
Numbers continued The Integer Data Type Multiple Declarations Parentheses Three Types of Errors.
Chapter 8 - Visual Basic Schneider
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Eight String Manipulation.
Introduction to Programming Fundamentals of Programming in Visual Basic.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Hungarian Notation A must in this course Every object used MUST be renamed including the form(s) using the following rules Form  frmFormName E.g. frmTemperature.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Eight String Manipulation.
CS4 –lecture 6 Wednesday, Jan 19, 2011 Roxana Gheorghiu.
© 2006 Lawrenceville Press Slide 1 Chapter 6 The Post-Test Do…Loop Statement  Loop structure that executes a set of statements as long as a condition.
Controlling Program Flow with Looping Structures
HNDIT Rapid Application Development
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
A FIRST BOOK OF C++ CHAPTER 14 THE STRING CLASS AND EXCEPTION HANDLING.
Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.
1 VB-06-String Manipulation Mar 03, 2002 String Function VISUAL BASIC.
Chapter 3 - VB 2008 by Schneider1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
© 2010 Lawrenceville Press Slide 1 Chapter 5 The Do…Loop Statement  Loop structure that executes a set of statements as long as a condition is true. 
COMPREHENSIVE Excel Tutorial 12 Expanding Excel with Visual Basic for Applications.
Chapter 3 - Visual Basic Schneider. Private Sub cmdEvaluate_Click() Dim n As Single, root As Single n = 6.76 root = Sqr(n) picResults.Print root; Int(n);
Introduction to Scripting
Input/Output Input/Output operations are performed using input/output functions Common input/output functions are provided as part of C’s standard input/output.
Fundamentals of Programming in Visual Basic
Fundamentals of Programming in Visual Basic
Section 3.3 Numbers Arithmetic Operations Variables
Variable Review & IO User 12/26/2018.
Chapter 3.5 Input and Output
Input and Output.
Prepared By: Deborah Becker
VBScript Session 10.
Additional Topics in VB.NET
Introduction to Programming
12th Computer Science – Unit 5
Input and Output.
Input and Output Chapter 3.5
Presentation transcript:

Input Dialog Box An input dialog box can be used to obtain a single item of input from the user Presents a window (dialog box) requesting input Syntax: stringVar = InputBox(prompt, title)

Example of an Input Dialog Box Private Sub cmdDisplay_Click() Dim fileName As String, prompt As String, title As String Dim houseNumber As Single, street As String prompt = "Enter the name of the file containing the information." title = "Name of File" fileName = InputBox(prompt, title) Open fileName For Input As #1 Input #1, houseNumber Input #1, street picAddress.Print "The White House is at"; houseNumber; street Close #1 End Sub After executing, an input dialog box will pop up

Using Message Dialog Box for Output The message dialog box is used to present a pop-up window containing information for the user Syntax: MsgBox prompt,, title

Example of a Message Dialog Box MsgBox “Nice try, but no cigar”,, “Consolation” Stays on the screen until the user presses OK

Formatting the Output: Create easily readable output In the Print method, the spacing of the output is controlled by the following devices:  semicolon  comma  Tab function

Semicolons The next value output is placed in the next column position. Example: picOutput.Print “Patrick”; ”Jon” Output: PatrickJon

Example of Semicolon picOutput.Print “Patrick”; “ Jon” Output Screen: Patrick Jon Space here

Example of Semicolon picOutput.Print 100; -200; 300 Output Screen: One space Two spaces

Commas A comma in a Print method causes the next value output to be placed in the next available print zone. Each print zone is 14 positions wide.

Using Commas Example: picOutput.Print “SEE”, ”YOU”, ”SOON” Output Screen: SEE YOU SOON Column 1 Column 15 Column 29

Using Commas A print zone can be skipped by typing consecutive commas Example: picOutput.Print “HOURLY”,, “PAY” Output Screen: HOURLY PAY Column 29

Tab Function Specifies the column where output will start Use only semicolons with the Tab function Can only be used to advance the print position (cannot move backwards)

Example of Tab Function Example: picOutput.Print Tab(3); “Hi there!” ; Tab(25) ;“Bye!” Output Screen: Hi there! Bye! Column 3 Column 25

Built-In Functions Take one or more input values and return an output value A means provided by Visual Basic for carrying out small, common tasks Types of Built-In functions  Numeric functions (manipulate numbers)  String functions (manipulate strings)

Numeric Functions

Example of Numeric Functions Private Sub cmdEvaluate_Click() Dim n As Single, root As Single n = 6.76 root = Sqr(n) picResults.Print root; Int(n); Round(n,1) End Sub Output:

Commonly-Used String Functions Function: Left(“Penguin”, 4) Purpose: Returns the number of characters specified, starting at the beginning of the string

Commonly-Used String Functions Function: Right(“Cork City”, 4) Purpose: Returns the number of characters specified from the end of the string

Commonly-Used String Functions Function: Mid(“Commissioner”, 4, 3) Purpose: Returns the substring starting at the position indicated by the first number and continuing for the length specified by the second number

Commonly-Used String Functions Function: UCase(“Yes”) Purpose: Converts any lowercase letters in a string to uppercase

String-Related Numeric Functions Function: InStr(“John Smith”, “m”) Purpose: Searches for the first occurrence of one string in another and gives the position at which the string is found

String-Related Numeric Function Function: Len(“John Smith”) Purpose: Returns the number of characters in the string.

Format Functions The format functions provide detailed control of how numbers, dates, and strings are displayed. Examples  FormatNumber ( , 1) 12,345.6  FormatCurrency ( , 2) $12,  FormatPercent (.185, 2) 18.50%  FormatNumber (1 + Sqr(2), 3) 2.414

Format Function Format (expr, Purpose: The value of this function is the value of expr right justified in a field of n spaces, where n is the number symbols.

Format Examples Format(12345, Format(123, 123 Format(“123.4”, 123.4

FormatDateTime Example FormatDateTime (“ ”, vbLongDate) Output: Monday, September 15, 2004

Rnd Function Returns a random number from 0 to 1. (excluding 1). Example: picBox.Print Int(6 * Rnd) + 1 Output: Displays a random integer from 1 through 6.