Question: Need help with the following assignment and code. Chapter 6 Homework - Website Traffic Metric REQUIREMENTS DOCUMENT Purpose: This Windows Desktop application finds the average

 Need help with the following assignment and code. Chapter 6 Homework

Need help with the following assignment and code. Chapter 6 Homework - Website Traffic Metric REQUIREMENTS DOCUMENT Purpose: This Windows Desktop application finds the average time in seconds spent on the opening page of a company's website, also called website traffic metrics or analytics. This market research is used to improve the effectiveness of the site. Program Procedures: A company wants to determine how much time is being spent on its opening page by computing the average in a Windows application. The application allows the user to enter up to 12 visitors' times in seconds spent on the opening webpage. The average website metric is displayed in seconds. Algorithms, Processing, and Conditions: 1. The user taps or clicks the Enter Visitor Analytics button to enter the number of seconds spent on the opening page of a company website. 2. Each time is displayed in a ListBox object with a scroll bar that appears when the number of values exceeds the given space. 3. After 12 values have been entered, the average is displayed. 4. If the user taps or clicks the Cancel button before entering any time values, display an appropriate message. Notes and Restrictions: 1. The result should include two places after the decimal point. 2. Non-numeric values should not be accepted. 3. Negative numbers should not be accepted. Comments: 1. The application allows integer entries. 2. Obtain an image for this program from CengageBrain.com. The name of the image file is the Website. USE CASE DEFINITION 1. The Windows application opens, displaying Website Traffic Estimate as to the heading, a ListBox object that will display the seconds spent on the opening page of the website with a scroll bar as needed, and a Button object that allows the user to enter the number of seconds spent on the page. 2. In an InputBox object, the user enters up to 12 values representing the number of seconds spent on the opening page. 3. The program asks the user for the number of seconds again if the value is a negative or non-numeric value. 4. The program displays the average time to two decimal places. 5. If the user taps or clicks the Cancel button in the input box before entering twelve (12) time values, the program uses the number of seconds entered for calculations. If the user enters no time values, an appropriate message is displayed. The code I have so far Public class frmWebsite Private Sub BtnEnter_Click(sender As Object, e As EventArgs) Handles BtnEnter.Click Dim str Spent Time As String Dim decSpent Time As Decimal Dim decAvgSpent Time As Decimal Dim decTotalSpent Time As Decimal = OD Dim strInputMessage As String = "Enter number of seconds spent on opening page" Dim strInputHeading As String = "Time Spent" Dim strNormalMessage As String = "Enter number of seconds spent on opening page" Dim strNonNumericError = MessageBox.Show("Please enter a numeric value greater then 0", "Entry Error", MessageBoxButtons.ok, MessageBox Icon.Error) Dim strNegativeError = MessageBox.Show("Please enter a numeric value greater then 0", "Entry Error", MessageBoxButtons.ok, MessageBox Icon.Error) Dim strCancelClicked As String = Dim intMaxNumberOfEntries As Integer = 12 Dim intNumOfEntries As Integer = 1 strSpentTime = InputBox(strInputMessage & intNumOfEntries, strInputHeading, "") Do Until intNumOfEntries > intMaxNumberOfEntries Or strSpentTime = strCancelclicked If IsNumeric(str Spent Time) Then decSpent Time = Convert.ToDecimal(str SpentTime) If decSpentTime> Then 1stDisplay.Items.Add(decSpent Time) decTotalSpent Time += decSpentTime intNumOfEntries += 1 strInputMessage = strNormalMessage Else strInputMessage = CType(strNegativeError, String) End If Else strInputMessage = CType (strNonNumericError, String) End If If intNumOfEntries 1 Then lblDisplay. Visible = True decAvgSpent Time = decTotalSpentTime / (intNumOfEntries - 1) lblDisplay.Text = "Average Time Spent: " & decAvgSpentTime.ToString("F2") & " Seconds" Else MessageBox.Show("No Time Values Entered", "Entry Error", MessageBoxButtons.OK, MessageBox Icon.Error) End If BtnEnter.Enabled = False End Sub End Class Ideally I would start the program and click the enter button, then start entering the number of second. However when I click the enter button the following message appears twice before allowing me to enter my numbers. What do I need to change in the code to get passed the error message as that is only supposed to appear when a non-numerical or negative number is type not as soon as the button is pressed. thanks ColechTook Zoom in Zoom Out Website Traffic Metrics Website Traffic Estimate Enter Visitor Analytics Entry Error X Please enter a numeric value greater then 0 OK

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!