Download presentation
Presentation is loading. Please wait.
Published byMyra Griffith Modified over 8 years ago
1
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 1
2
Testing for Valid Numeric Input Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 2
3
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 3
4
Create a project including the form below. Name the text box, txtTest. Code the Exit button. Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc.Slide 4
5
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 5
6
Murach’s Visual Basic 2008, C7, modified or added © 2008, Mike Murach & Associates, Inc. Slide 6
7
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 7
8
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 8
9
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 9
10
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 10
11
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 11
12
An Exception is an Object with Properties Methods Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc.12
13
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 13
14
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 14
15
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 15
16
Practice Exercise Create a project that will allow you to test the code on Slide 14. The code should be activated when a button is clicked. What is accomplished by the last argument of MessageBox.Show, ex.GetType.ToString? Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc.16
17
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 17
18
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 18
19
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 19
20
Convert Class vs. Conversion Functions CInt(10.5) rounds to 10 – always rounds Convert.ToInt32(10.5) – throws a Format Exception Which do you want? CInt(x) – throws an Invalid Cast Exception Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc.20
21
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 21
22
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 22
23
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 23
24
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 24
25
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 25
26
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 26
27
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 27
28
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 28
29
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 29
30
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 30
31
Do #1-4 on page 221 Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc.31
32
Data Validation: Three Common Types Did the user enter anything? Did the entry convert to the required data type? Was the entry within the required range? Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc.32
33
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 33
34
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 34
35
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 35
36
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 36
37
Data Validation for All User Input Code for all three common checks for every textbox Is there an easier method? Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc.37
38
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 38
39
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 39
40
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 40
41
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 41
42
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 42
43
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 43
44
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 44
45
Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc. Slide 45
46
To Learn More: Do p. 221 Exercise 7-1 #1-7 (In #5, use only a single Return statement.) Do p. 222 Exercise 7-2 #1-7 Murach’s Visual Basic 2008, C7, modified or added© 2008, Mike Murach & Associates, Inc.46
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.