Download presentation
Presentation is loading. Please wait.
Published byKory Elliott Modified over 8 years ago
1
Introduction to Computer CC111 Week 10 Visual Basic 3 1
2
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Intended Learning Objectives Use Visual Basic Input/Output Understand Errors Understand Event Driven Programming Use Conditions & If statements Use loops Be Able to build a simple Visual Basic Application.
3
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 3 The Three Steps in Creating a Visual Basic 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.
4
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 4 Code Editor Code Editor tab Form Designer tab
5
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Automatic Colorization Comments – green String literals – maroon Keywords – blue Class Name – turqoise Note: Examples of keywords are Handles, Sub, and End. Examples of class names are Form1, Math, and MessageBox. 5
6
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 6 Three Types of Errors Syntax error Runtime error Logic error
7
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 7 Some Types of Syntax Errors Misspellings lstBox.Itms.Add(3) Omissions lstBox.Items.Add(2 + ) Incorrect punctuation Dim m; n As Integer
8
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 8 Auto Correction
9
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. A Type of Runtime Error Overflow error Dim numVar As Integer = 1000000 numVar = numVar * numVar 9 Remember Integer data type is 4 byte in memory and accepts values from +/- 2,147,483,647
10
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 10 A Logical Error Dim average As Double Dim m As Double = 5 Dim n As Double = 10 average = m + n / 2 Value of average will be 10. Should be 7.5.
11
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. The Sub Statement Where Private is the default procedure type Sub indicates beginning of procedure controlname is name of associated control _ (underscore) required separator eventname is name of corresponding event ( ) set of parentheses is required End Sub indicates end of a procedure Private Sub ControlName_eventName(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ControlName.eventName` End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Const pi = 3.14 Dim r As Integer Dim area As Double r = Val(TextBox1.Text) area = pi * r * r Label3.Text = Str(area) End Sub Example on the Sub Statement
12
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Input / Output to User Interface Controls Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i As Double Dim o As Double i = Val(TextBox1.Text) o = i / 5 * 2 Label2.Text = ”Output=" + Str(o) TextBox2.Text = Str(o) End Sub
13
13 Getting Input from an Input Dialog Box stringVar = InputBox(prompt, title) fullName = InputBox("Enter your full name.", "Name") title prompt
14
14 Using a Message Dialog Box for Output MessageBox.Show(prompt, title) MessageBox.Show("A MessageBox with a title.", "WPF") title prompt
15
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Display Events for a Control Select the control Click on the Events button in the Properties window 15 Events button
16
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 16 Structure of an Event Procedure Private Sub objectName_event(...) Handles objectName.event statements End Sub (...) is filled automatically with (sender As System.Object, e As System.EventArgs) header
17
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 17 Create an Outline for an Event Procedure Double-click on a control or Select a control, click on the Events button in the Properties window, and double-click on an event (We nearly always use the first method.)
18
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 18 Sample Form Double-click on txtFirst to create the outline for the Code Editor txtFirst txtSecond btnRed
19
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 19 Code for Walkthrough Public Class frmDemo Private Sub txtFirst_TextChanged(...) Handles txtFirst.TextChanged txtFirst.ForeColor = Color.Blue End Sub End Class
20
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 20 IntelliSense Automatically pops up to help the programmer. txtFirst.
21
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 21 Sample Form txtFirst txtSecond btnRed Double-click on btnRed to return to Code Editor and add the outline of an event procedure.
22
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 22 Code for Walkthrough Public Class frmDemo Private Sub txtFirst_TextChanged(...) Handles txtFirst.TextChanged txtFirst.ForeColor = Color.Blue End Sub Private Sub btnRed_Click(...) Handles btnRed.Click txtFirst.ForeColor = Color.Red End Sub End Class
23
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 23 Event Procedure txtFirst.Leave Select txtFirst on the form Click on the Events button in the Properties window Double-click on Leave
24
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 24 Code for Walkthrough Private Sub txtFirst_Leave(...) Handles txtFirst.Leave txtFirst.ForeColor = Color.Black End Sub Private Sub txtFirst_TextChanged(...) Handles txtFirst.TextChanged txtFirst.ForeColor = Color.Blue End Sub Private Sub btnRed_Click(...) Handles btnRed.Click txtFirst.ForeColor = Color.Red End Sub
25
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 25 Header of Event Procedure Private Sub btnRed_Click(…) Handles btnRed.Click Identifies eventName, can be changed. Private Sub Button_Press(…) Handles btnRed.Click
26
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 26 Handling Multiple Events Private Sub Happening(...) _ Handles btnRed.Click,txtSecond.Leave txtFirst.ForeColor = Color.Red End Sub An event procedure can be invoked by two events.
27
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 27 Altering Properties of the Form The following won't work: frmDemo.Text = "Demonstration" The form is referred to by the keyword Me. Me.Text = "Demonstration"
28
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Functions Function - unit of code that returns a value Built-in Functions Examples: – Math.Sqrt - square root – Rnd - random number generator – Int - returns integer portion of a number – Val - converts a string to a value – CStr - converts a value to a string
29
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 29 Condition A condition is an expression involving relational and/or logical operators. Result of the condition is True or False.
30
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 30 Example When a = 3, b = 4 (a + b) < 2 * a 3 + 4 = 7 2 * 3 = 6 7 is NOT less than 6 and so the value of the expression is False
31
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 31 Another Example a = 4 b = 3 c = "hello“ ( c.Length – b ) = ( a / 2 ) 5 – 3 = 24 / 2 = 2 True because 2 equals 2
32
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 32 Relational Operator Notes Relational operators are binary – they require an operand on both sides of the operator Value of a relational expression will always be True or False
33
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 33 Boolean Expression An expression that evaluates to either True or False is said to have Boolean data type. Example: The statement txtBox.Text = CStr((2 + 3) < 6) displays True in the text box.
34
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 34 If Block The following program will take a course of action based on whether a condition is true. If condition Then action 1 Else action 2 End If Will be executed if condition is true Will be executed if condition is false
35
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 35 Another example If Block If condition Then action 1 End If Statement 2 Statement 3 Regardless of whether the condition in the If statement is true or false, these statements will be executed
36
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 36 Pseudocode and Flowchart for an If Block
37
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 37 Application 1: Find Maximum txtFirstNum txtSecondNum txtResult
38
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 38 Application 1: Code Private Sub btnFindLarger_Click(...) _ Handles btnFindLarger.Click Dim num1, num2, largerNum As Double num1 = CDbl(txtFirstNum.Text) num2 = CDbl(txtSecondNum.Text) If num1 > num2 Then largerNum = num1 Else largerNum = num2 End If txtResult.Text = "Larger number: " & largerNum End Sub
39
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 39 Application 1: Output
40
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 40 Do Loops A loop is one of the most important structures in programming. Used to repeat a sequence of statements a number of times. The Do loop repeats a sequence of statements either as long as or until a certain condition is true.
41
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 41 Pretest Do Loop Do While condition statement(s) Loop These statements are inside the body of the loop and are run if the condition above is true. Condition is tested, If it is true, the loop is run. If it is false, the statements following the Loop statement are executed.
42
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 42 Pseudocode and Flow Chart
43
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 43 Example: Repeat Request as Long as Response in Incorrect Dim passWord As String = "" Do While passWord <> "SHAZAM" passWord = InputBox("What is the password?") passWord = passWord.ToUpper Loop passWord is the loop control variable because the value stored in passWord is what is tested to determine if the loop should continue or stop.
44
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 44 Posttest Do Loop Do statement(s) Loop Until condition Loop is executed once and then the condition is tested. If it is false, the loop is run again. If it is true, the statements following the Loop Until statement are executed.
45
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 45 Example: Repeat Request Until Proper Response Dim passWord As String = "" Do passWord = InputBox("What is the password?") passWord = passWord.ToUpper Loop Until passWord = "SHAZAM"
46
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 46 Pseudocode and Flowchart
47
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 47 Application 2: Interest Over Years txtAmount txtWhen
48
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 48 Application 2: Code Private Sub btnCalculate_Click(...) Handles _ btnCalculate.Click Dim balance As Double, numYears As Integer balance = CDbl(txtAmount.Text) Do While balance < 1000000 balance += 0.06 * balance numYears += 1 Loop txtWhen.Text = "In " & numYears & " years you will have a million dollars." End Sub
49
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 49 Application 2: Output
50
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 50 For…Next Loops General Form of a For…Next Loop Step Keyword Used when we know how many times we want the loop to execute A counter controlled loop
51
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 51 For…Next Loop Syntax
52
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 52 Application 3: Population Estimation
53
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. 53 Application 3: Code Dim pop As Double = 300000 For yr As Integer = 2012 To 2016 lstTable.Items.Add(yr & " " & pop.ToString("N0") pop += 0.03 * pop Next
54
Small Applications Examples Optional
55
Application 4: Calculate the area of a circle Inputs: radius of the circle r Output: area of the circle Process: Area=
56
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Application 4: Calculate the area of a circle (Form View) Circle_Area_Calculator.exe
57
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Application 4: Calculate the area of a circle (Code View) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Const pi As Double= 3.14 Dim r As Integer Dim area As Double r = Val(TextBox1.Text) area = pi * r * r Label3.Text = Str(area) End Sub
58
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Application 4: Calculate the area of a circle (Run)
59
Simple Examples of Equations normal Equation in normal form: 1.Y=3X 2.Y=X-10+3(X-Z) 3.Y= VB Equation in VB form: 1.Y=3*X 2.Y=X-10+3*(X-Z) 3.Y= Math.Sqrt(X)
60
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Application 5: Convert from Fahrenheit Degree to Celsius Original formula: Celsius=5/9 (Fahrenheit - 32) Visual Basic formula: Celsius=5/9*(Fahrenheit-32) Input: Fahrenheit Output: Celsius Process: Celsius=5/9*(Fahrenheit-32)
61
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Application 5 Convert from Fahrenheit Degree to Celsius (Form View) Temprature_Convert.exe
62
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Application 5 Convert from Fahrenheit Degree to Celsius (Code View) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f As Double Dim c As Double f = Val(TextBox1.Text) c = 5 / 9 * (f - 32) Label2.Text = "Celsius=" + Str(c) End Sub The + operator is used to concatenate strings Note:
63
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Application 5 Convert from Fahrenheit Degree to Celsius (Run)
64
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Application 6 The Wind Chill Application Write a program that calculates the wind chill temperature Inputs: Wind Speed and Temperature Outputs: Wind Chill Temperature
65
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Application 6 The Wind Chill Application Original formula WC = 0.0817(3.71(V **0.5) + 5.81 - 0.25V)(T - 91.4) + 91.4 Visual Basic statement WC = 0.0817 * (3.71 * Sqr(V) + 5.81 -(0.25 * V)) * (T - 91.4) + 91.4 Output: Wind Chill (WC) Input 1 T: Temperature Input 2 V: Wind Speed
66
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Adding Controls and Changing their Properties
67
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Writing the Code Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim V As Integer Dim T As Integer Dim WC As Double v = Val(TextBox1.Text) T = Val(TextBox2.Text) WC = 0.0817 * (3.71 * Math.Sqrt(V) + 5.81 - (0.25 * V)) * (T - 91.4) + 91.4 TextBox3.Text = Str(WC) End Sub
68
© 2013 Cengage Learning. All Rights Reserved. This edition is intended for use outside of the U.S. only, with content that may be different from the U.S. Edition. May not be scanned, copied, duplicated, or posted to a publicly accessible website, in whole or in part. Running the Application
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.