1 INF110 Visual Basic Programming AUBG Spring semester 2011 Reference books: Schneider D., An Introduction to Programming Using Visual Basic, Prentice.

Slides:



Advertisements
Similar presentations
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5- 1 STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
Advertisements

Chapter 2 –Visual Basic, Controls, and Events
Fundamentals of Programming in Visual Basic
Chapter 31 Fundamentals of Programming in Visual Basic (Continue IV) Strings Variables and Strings Using Text Boxes for Input and Output Concatenation.
Chapter 31 Visual Basic Controls A Form is a windows-style screen displayed by Visual Basic programs. In a form, a programmer can create objects in a form.
Chapter 2 –Visual Basic, Controls, and Events
Variables & Math Operators CE 311 K - Introduction to Computer Methods Daene C. McKinney.
1 INF110 Visual Basic Programming AUBG Spring semester 2011 Reference books: Schneider D., An Introduction to Programming Using Visual Basic, Prentice.
Chapter 3 - VB 2008 by Schneider1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Chapter 31 Fundamentals of Programming in Visual Basic (Continue VI) String Properties and Methods: "Visual".Length is 6. "Visual".ToUpper is VISUAL. "123.
1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Created By Mayson Al-Duwais1. Using Exit to Terminate Repetition Statements To terminate different types of repetition statements you can use a special.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
1 INF110 Visual Basic Programming AUBG Spring semester 2011 Reference books: Schneider D., An Introduction to Programming Using Visual Basic, Prentice.
Visual Basic Chapter 1 Mr. Wangler.
CS0004: Introduction to Programming Variables – Numbers.
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
© Minder Chen, ASP.NET 2.0: Introduction - 1 ASP.NET 2.0 Minder Chen, Ph.D. Framework Base Class Library ADO.NET: Data & XML.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
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.
Chapter 3 - VB 2005 by Schneider1 Chapter 3 – Fundamentals of Programming in Visual Basic 3.1 Visual Basic Controls 3.2 Visual Basic Events 3.3 Numbers.
CS0004: Introduction to Programming Variables – Strings.
1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 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.
Chapter 3 – Fundamentals of Programming in VB.NET VB.NET Controls VB.NET Events Numbers Strings Input and Output.
Introduction to Visual Basic.NET Chapter 2 Introduction to Controls, Events.
 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.
Microsoft Visual Basic 2005 CHAPTER 4 Variables and Arithmetic Operations.
Chapter 2 –Visual Basic, Controls, and Events
CS0004: Introduction to Programming Project 1 – Lessons Learned.
Chapter 2 - VB 2008 by Schneider1 Chapter 2 –Visual Basic, Controls, and Events 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual.
Numbers continued The Integer Data Type Multiple Declarations Parentheses Three Types of Errors.
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.
3.2 VB.NET Events An Event Procedure Properties and Event Procedures of the Form Tab Order of Controls Exercises.
1 Advanced Computer Programming Lab Calculator Project.
Chapter 3 - VB.NET by Schneider1 Chapter 3 – Fundamentals of Programming in VB.NET Part I VB.NET Controls VB.NET Events.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
1 Chapter 3 – Examples The examples from chapter 3, combining the data types, variables, expressions, assignments, functions and methods with Windows controls.
CS4 –lecture 6 Wednesday, Jan 19, 2011 Roxana Gheorghiu.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
3.4 Strings Variables and Strings Using Text Boxes for Input and Output Concatenation ANSI Character Set String Properties and Methods: LengthToUpper TrimToLower.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Chapter 2 - VB 2008 by Schneider1 Chapter 2 –Visual Basic, Controls, and Events 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual.
Chapter 3 - VB 2008 by Schneider1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
ALMAJMA'AH UNIVERSITY College of Science and Humanitarians Studies in Alghat Information Technology Section (211Tal course) 1.
Microsoft Visual Basic 2010 CHAPTER FOUR Variables and Arithmetic Operations.
Visual Basic Fundamental Concepts
Visual Basic.NET Windows Programming
Variables and Arithmetic Operations
3.01 Apply Controls Associated With Visual Studio Form
3.01 Apply Controls Associated With Visual Studio Form
Chapter 3 – Variables, Input, and Output
Variables and Arithmetic Operations
Chapter 3 – Variables, Input, and Output
Fundamentals of Programming in VB.NET
Strings(Part 1) String Literal and String Variable
String Variable, Methods and Properties
Section 3.3 Numbers Arithmetic Operations Variables
Variable Review & IO User 12/26/2018.
String Variable, Methods and Properties
String Variable, Methods and Properties
Introduction to Programming
String Variable, Methods and Properties
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Presentation transcript:

1 INF110 Visual Basic Programming AUBG Spring semester 2011 Reference books: Schneider D., An Introduction to Programming Using Visual Basic, Prentice Hall, Pearson Education Inc., 7th Ed. 2008, 6th Ed Liberty J., Learning Visual Basic.NET, O’Reilly, 2002 Any Visual Basic book available in AUBG library Course lecturer: Assoc. Prof. Svetla Boytcheva, PhD

2 INF110 Visual Basic Programming AUBG Spring semester 2011 Lecture 14 Title: Windows Based Applications 2 ListBox control Practical 2: Data, Assignment

3 Lecture Contents: §Windows applications – basic concepts l OOP l Event driven Programming §Form §Controls – label, edit box, button §Procedures - Event handlers §Visual Studio IDE §Three steps to develop Windows applications §Demo programs – Input/Output

4

5 Windows Applications Using the Visual Studio.NET Development Environment INF110 Visual Basic Programming

6 VBasic Applications Console Applications Windows Applications Web (ASP.NET) Applications

7 Fundamentals of Windows Applications Object Oriented Programming –Classes + Objects = Programs Event Driven Programming –The flow of the program is controlled by the user

8 Visual Basic is an event-driven language Therefore, a Visual Basic program is made up of many “subprograms”, known as event handlers. Each subprogram: has its own program code, can be executed independently, at the same time each can be linked together in one way or another.

9 VB.NET displays a Window-style screen (called a form) with: boxes into which users type information and/or in which users edit information; buttons that users click to initiate actions. The boxes and buttons are referred to as controls. The most common controls are: - Text boxes - Labels - Buttons - List boxes

10 The three steps in creating a VB.NET program 1.Create the interface; that is, generate, position, and size the objects. 2.Set properties; that is, configure the appearance of the objects. 3.Write the code that executes when events occur.

11 Solution explorer window Form window Toolbox window Properties window Menu bar Tool bar Main area

12 The Toolbox contains a list of controls (icons). Using the Toolbox, you may add controls to your “user interface”, i.e. you may develop a screen for your program.

13 Chapter 2 - VB 2008 by Schneider13 Auto Hide Hides Toolbox when not in use Vertical push pin icon indicates auto hide is disabled. Click the push pin to make it horizontal and enable auto hide. Push pin

14 Positioning and Aligning Controls VB provides the following tools: Proximity Lines – short line segments that help you place controls a comfortable distance from each other and from the sides of a form Snap lines – horizontal and vertical line segments that help you align controls

15 Chapter 2 - VB 2008 by Schneider15 Positioning Controls Proximity line

16 Chapter 2 - VB 2008 by Schneider16 Aligning Controls Snap line

17 Chapter 2 - VB 2008 by Schneider17 Aligning Controls Snap line

18 The ListBox control another control that has a number of lines to be displayed instead of a single line as with a text box.

19 Numeric Data How to show numeric data on the screen? One way to show a number on the screen is to use a list box - another control that has a number of lines to be displayed instead of a single line as with a text box. If n is a number or in other words a numeric literal, (instead of txtBox.Text = CStr(n) ) the statement lstBox.Items.Add(n) displays the number n as the last item in the list box. Add() is called a method. lstBox.Items.Clear() erases all items displayed in a list box. Clear() is another method.

20 Numeric Data – Literals How to show literal numeric data on the screen? Arguments of method Add() specified as literals Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click lstResults.Items.Clear() lstResults.Items.Add(3 + 2) lstResults.Items.Add(3 - 2) lstResults.Items.Add(3 * 2) lstResults.Items.Add(3 / 2) lstResults.Items.Add(3 \ 2) lstResults.Items.Add(3 ^ 2) lstResults.Items.Add(2 * (3 + 4)) End Sub

21 Alternative: Use With block Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click With lstResults.Items.Clear().Add(3 + 2).Add(3 - 2).Add(3 * 2).Add(3 / 2).Add(3 \ 2).Add(3 ^ 2).Add(2 * (3 + 4)) End With End Sub

22 Numeric Data – Variables How to show variable contents numeric data on the screen? Arguments of method Add() specified as variables As well as literal values, may also use variable names with list box functions (better to say methods). E.g. lstResults.Items.Add(timeElapsed) where timeElapsed is the name of some variable.

23 E.g. Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click Dim a As Double Dim b As Double = 3 a = 5 lstResults.Items.Clear() lstResults.Items.Add(a) lstResults.Items.Add(b) lstResults.Items.Add(a * (2 + b)) End Sub

24 Built-in Numeric Functions Math.Sqrt() calculates the square root of a number. Math.Int() finds the greatest integer number less than or equal to a value, specified as an argument. Math.Round() rounds a value. Plus many others. Math.Sqrt(9) returns 3 Int(9.7) returns 9 Math.Round(2.7) returns 3

25 Symbolic Data – string variables and string literals How to show symbolic data on the screen? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim today As String today = “Friday" lstOutput.Items.Clear() lstOutput.Items.Add("hello") lstOutput.Items.Add(today) End Sub

26 Symbolic Data – string variables and string literals How to show symbolic data on the screen? Private Sub btnDisplay_Click(...) Handles btnDisplay.Click Dim today As String today = “Friday" With lstOutput.Items.Clear().Add("hello").Add(today) End With End Sub

27 String Properties and Methods: Length - property ToUpper – method Trim – method ToLower - method IndexOf - methodSubstring - method If Str is a string Str.Length is the number of characters in the string Str.ToUpper converts all characters to uppercase Str.ToLower converts all characters to lowercase Str.Trim removes all spaces from the front and back

28 Str.Substring(m, n) picks out the substring beginning at character in position m and having length of n. The start leftmost position is numbered zero /0/. “abcdefghijklmnopqrstuvwxyz” m = 4 n = 15 gives “efghijklmnopqrs” If n is omitted, the n is taken to mean the end of the string.

29 Str.IndexOf(SubStr) returns the value -1 if SubStr is not a substring of Str, otherwise returns the start position in Str of the substring SubStr.

30 "Visual".Length is:6 "Visual".ToUpper is:VISUAL "123 Hike".Length is:8 "123 Hike".ToLower is:123 hike "a" & " bcd ".Trim & "efg" is:abcdefg Example

31 "fanatic".Substring(0, 3) is:fan "fanatic".IndexOf("ati") is:3 "fanatic".Substring(4, 2) is:ti "fanatic".IndexOf("a") is:1 "fanatic".Substring(4) is:tic "fanatic".IndexOf("nt") is:–1 Example (cont.)

32 Using Text Boxes for Input and Output The contents of a text box is always a string Input example strVar = txtBox.Text assigns to variable strVar the value of the Text field. Output example txtBox.Text = strVar

33 Concatenation Combining two strings to make a new string - & quote1 = “To be, " quote2 = “or not to be." quote = quote1 & quote2 txtOutput.Text = quote & “ That is the question." Displays To be, or not to be. That is the question.

34 Example – parses a name Dim fullName, firstName, lastName As String Dim n As Integer fullName = txtName.Text n = fullName.IndexOf(" ") firstName = fullName.Substring(0, n) lastName = fullName.Substring(n + 1) With lstResults.Items.Clear().Add("First name: " & firstName).Add(“Last name has " & lastName.Length & “ letters.") End With

35 Data Conversion Because the contents of a text box is always a string, sometimes you must convert the input or output numVar = CDbl(txtBox.Text) txtBox.Text = CStr(numVar) CDbl - Converts a String to a Double CStr - Converts a number to a string

36 Also, CInt() converts a String to an Integer

37 The Empty String The string "", which contains no characters, is called the empty string or the zero-length string. The statement lstBox.Items.Add("") skips a line in the list box. The contents of a text box can be cleared with either the statement txtBox.Clear() or the statement txtBox.Text = ""

38 Initial Value of a String By default the initial value is Nothing, null reference Strings can be given a different initial value as follows: Dim today As String = “Friday" Or assigned a value at runtime

39 Dim n As Integer Try n = CInt(TextBox1.Text) Catch ex As Exception MessageBox.Show("please, insert integer", "textbox1", MessageBoxButtons.OK, MessageBoxIcon.Error) Return End Try If CheckBox1.Checked Then n = n * n End If Label1.Text = n

Dim s As String = TextBox2.Text ListBox1.Items.Clear() For Each c In s ListBox1.Items.Add(c) Next 40

41 Windows Applications Demo programs by Schneider, Chapter 03 No 3.5 (input/output) INF110 Visual Basic Programming

42 Fundamentals Fundamentals of Programming in VB.NET

43 Numbers

44 Example Program applies each of the five arithmetic operators to operands numbers 3 and 2. Design: a Form,2 controls: List Box, Button ObjectPropertySetting Form1Text3-3-1 lstResults btnComputeTextCompute

45 Example 3.3-1

46 Example Option Strict On Public Class Form1 Inherits System.Windows.Forms.Form ‘Windows Form Designer generated Code Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click lstResults.Items.Clear() lstResults.Items.Add(3 + 2) lstResults.Items.Add(3 - 2) lstResults.Items.Add(3 * 2) lstResults.Items.Add(3 / 2) lstResults.Items.Add(3 ^ 2) lstResults.Items.Add(2 * (3 + 4)) End Sub Private Sub lstResults_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstResults.SelectedIndexChanged End Sub End Class

47 Example Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click lstResults.Items.Clear() lstResults.Items.Add(3 + 2) lstResults.Items.Add(3 - 2) lstResults.Items.Add(3 * 2) lstResults.Items.Add(3 / 2) lstResults.Items.Add(3 ^ 2) lstResults.Items.Add(2 * (3 + 4)) End Sub

48 Example Run the program. Test the program. Modify the program and rerun it again.

49 Numbers in scientific notation b * 10 r is usually written as bEr ==================================== 1.4*10^9 1.4E+9 1.4E ==================================== 3*10^-7 3E

50 Example Program illustrates scientific notation. Same design as example Design: a Form,2 controls: List Box, Button ObjectPropertySetting Form1Text3-3-2 lstResults btnComputeTextCompute

51 Example 3.3-2

52 Example Priavate Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click lstResults.Items.Clear() lstResults.Items.Add(1.2 * 10 ^ 34) lstResults.Items.Add(1.2 * 10 ^ 8) lstResults.Items.Add(1.2 * 10 ^ 3) lstResults.Items.Add(10 ^ -20) lstResults.Items.Add(10 ^ -2) End Sub

53 Example 3.3-2m Using With … End With Priavate Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click With lstResults.Items.Clear().Add(1.2 * 10 ^ 34).Add(1.2 * 10 ^ 8).Add(1.2 * 10 ^ 3).Add(10 ^ -20).Add(10 ^ -2) End With End Sub

54 Example Run the program. Test the program. Modify the program and rerun it again.

55 Variables variables

56 Example Program displays default value of a variable and the value of an expression. Same design as example Design: Form, ListBox, Button ObjectPropertySetting Form1Text3-3-3 lstResults btnComputeTextCompute

57 Example 3.3-3

58 Example Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click Dim a As Double Dim b As Double = 3 lstResults.Items.Clear() lstResults.Items.Add(a) lstResults.Items.Add(b) a = 5 lstResults.Items.Add(a * (2 + b)) End Sub

59 Example Run the program. Test the program. Modify the program and rerun it again.

60 Built-in Functions Math.Sqrt Int Math.Round

61 Example Program evaluates each of the functions for a specific input given by the value of a variable n Same design as example Design: Form, ListBox, Button ObjectPropertySetting Form1Text3-3-4 lstResults btnEvaluateTextEvaluate

62 Example Private Sub btnEvaluate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEvaluate.Click Dim n As Double Dim root As Double n = 6.76 root = Math.Sqrt(n) With lstResults.Items.Clear().Add(root).Add(Int(n)).Add(Math.Round(n, 1)) End With End Sub

63 Example Run the program. Test the program. Modify the program and rerun it again.

64 Example Program evaluates each of the functions for argument specified as an expression. Same design as example Design: Form, ListBox, Button ObjectPropertySetting Form1Text3-3-5 lstResults btnEvaluateTextEvaluate

65 Example Private Sub btnEvaluate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEvaluate.Click Dim a As Double Dim b As Double a = 2 b = 3 With lstResults.Items.Clear().Add(Math.Sqrt(5 * b + 1)).Add(Int(a ^ b + 0.8)).Add(Math.Round(a / b, 3)) End With End Sub

66 Example Run the program. Test the program. Modify the program and rerun it again.

67 Strings

68 Example Variables and Strings Program shows how assignment statement and the.Add method are used with strings. Design: Form, ListBox, Button ObjectPropertySetting Form1Text3-4-1 lstOutput btnDisplayTextDisplay Strings

69 Example Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click Dim today As String today = “Friday" With lstOutput.Items.Clear().Add("hello").Add(today) End With End Sub

70 Example Run the program. Test the program. Modify the program and rerun it again.

71 Example Using text boxes for Input and Output Program computes the sum of two numbers supplied by the user. Design: Form, 3 Labels, 3 Text Boxes, Button Examine the ReadOnly property for Text Boxes

72 Example Text Box controls The ReadOnly property: Controls whether the text in the edit control can be changed by the user or not ReadOnly: True /gray background/ text can not be changed by the user ReadOnly: False /white background/ text can be changed by the user

73 Example 3-4.2

74 Example Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click Dim sum As Double sum = CDbl(txtFirstNum.Text) + CDbl(txtSecondNum.Text) txtSum.Text = CStr(sum) End Sub

75 Example Run the program. Test the program. Modify the program and rerun it again.

76 Example Concatenation Program illustrates concatenation of strings. Design: Form, Text Box, Button

77 Example 3-4.3

78 Example Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click Dim quote1, quote2, quote As String quote1 = "The ballgame isn't over, " quote2 = "until it's over." quote = quote1 & quote2 txtOutput.Text = quote & " Yogi Berra " End Sub

79 Example Run the program. Test the program. Modify the program and rerun it again.

80 Example Concatenation Program concatenates a string with a number. Design: Form, Text Box, Button

81 Example 3-4.4

82 Example Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click Dim str As String, numOfKeys As Double str = "The piano keyboard has " numOfKeys = 88 txtOutput.Text = str & numOfKeys & " keys." End Sub

83 Example Run the program. Test the program. Modify the program and rerun it again. How many keys has a standard PC keyboard?

84 Example String Properties and Methods: Length property ToUpper, ToLower, Trim, IndexOf, Substring methods Program uses variables and expressions with properties and methods. Design: Form, Text Box, Button

85 Example Private Sub btnEvaluate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEvaluate.Click Dim str1, str2 As String str1 = "Quick as " str2 = "a wink" With lstResults.Items.Clear().Add(str1.Substring(0, 7)).Add(str1.IndexOf("c")).Add(str1.Substring(0, 3)).Add((str1 & str2).Substring(6, 6)).Add((str1 & str2).ToUpper).Add(str1.Trim & str2).Add("The average " & str2.Substring(str2.Length - 4) & " lasts.1 second.") End With End Sub

86 Example 3-4.5

87 Example Run the program. Test the program. Modify the program and rerun it again. Change the following statements:.Add((str1 & str2).ToUpper).Add(str1.Trim & str2) To.Add((str1 & str2).ToUpper() ).Add(str1.Trim() & str2) Moral: Subs and Functions with no arguments may be called with or without parentheses ()

88 Example String Properties and Methods: Length property ToUpper, ToLower, Trim, IndexOf, Substring methods Program parses a name. Design: Form, Text Box, Button

89 Example 3-4.6

90 Example Private Sub btnAnalyze_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnalyze.Click Dim fullName, firstName, lastName As String Dim n As Integer fullName = txtName.Text n = fullName.IndexOf(" ") firstName = fullName.Substring(0, n) lastName = fullName.Substring(n + 1) With lstResults.Items.Clear().Add("First name: " & firstName).Add("Your last name has " & lastName.Length & " letters.") End With End Sub

91 Example Run the program. Test the program. Modify the program and rerun it again.

92 Example Internal documentation Program rewrites example with inclusion of comments. Design: Form, Text Box, Button

93 Example Private Sub btnAnalyze_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnalyze.Click 'Determine a person's first name and the length of the second name Dim fullName, firstName, lastName As String Dim n As Integer 'Location of the space separating the two names fullName = txtName.Text n = fullName.IndexOf(" ") firstName = fullName.Substring(0, n) lastName = fullName.Substring(n + 1) 'Display the desired information in a list box With lstResults.Items.Clear().Add("First name: " & firstName).Add("Your last name has " & lastName.Length & " letters.") End With End Sub

94 Example Run the program. Test the program. Modify the program and rerun it again.

95 Task A Text Box Walkthrough Create a Text Box control Activate the properties window Trace the effect of modifying some properties: –Appearance: Text, BackColor, ForeColor, Font, BorderStyle –Design: (Name) –Layout: Location, Size

96 Task A List Box Walkthrough Create a List Box control Activate the properties window Trace the effect of modifying some properties: –Appearance: Text, BackColor, ForeColor, Font, BorderStyle –Design: (Name) –Layout: Location, Size

97 Task A Label Walkthrough Create a Label control Activate the properties window Trace the effect of modifying some properties: –Appearance: Text, BackColor, ForeColor, Font –Design: (Name) –Layout: Location, Size

98 Task A Button Walkthrough Create a Button control Activate the properties window Trace the effect of modifying some properties: –Appearance: Text, TextAlign, BackColor, ForeColor, Font –Design: (Name) –Layout: Location, Size

99 Questions?

100 Thank You For Your Attention!