Question
Clearly Visual Basic 2012 Chapter 19 Exercise 4 Page 450 In this exercise, you modify the West Coast Emporium application coded in the chapter. Use
Clearly Visual Basic 2012 Chapter 19 Exercise 4 Page 450 In this exercise, you modify the West Coast Emporium application coded in the chapter. Use Windows to make a copy of the West Coast Solution folder. Save the copy in the ClearlyVB2012\Chap19 folder. Rename the copy Modified West Coast Solution. Open the West Coast Solution (West Coast Solution.sln) file contained in the Modified West Coast Solution folder.
1. Open the designer window. Change the btnNumberOfStores controls name to btnDisplay, and change its Text property to &Display. 2. Modify the interface so that it also displays the number of employees in the state entered by the user. 3. Declare another class-level array to store the number of employees in each state. Use your own values to initialize the array. 4. Locate the btnNumberOfStores_Click procedure. Change the name to btnDisplay_Click and then modify the code to also display the number of employees. ' Name: West Coast Project ' Purpose: Display the number of stores in a state ' Programmer:
Public Class frmMain ' class-level parallel arrays Private strStates() As String = {"CA", "OR", "WA"} Private intStores() As Integer = {110, 75, 63} Private Sub txtState_TextChanged(sender As Object, e As EventArgs) Handles txtState.TextChanged lblStores.Text = String.Empty End Sub Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Me.Close() End Sub Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click ' searches an array for a state ID and then ' displays either the number of stores ' from another array or 0 ' declare variables Dim strSearchFor As String Dim intSub As Integer Dim strFound As String
' assign the ID to a variable strSearchFor = txtState.Text.Trim.ToUpper
' search the strStates array for the ID ' continue searching until the ID is ' found or the end of the array intSub = 0 strFound = "N" Do Until strFound = "Y" OrElse intSub = strStates.Length If strStates(intSub) = strSearchFor Then strFound = "Y" Else intSub = intSub + 1 End If Loop ' determine whether the ID was found ' and display the appropriate output If strFound = "Y" Then lblStores.Text = intStores(intSub) Else lblStores.Text = "0" End If End Sub Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub End Class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started