Question: I've been stuck on this problem for over 2 hours and i can't figure it out yet it seems so simple. Question: In this exercise,

I've been stuck on this problem for over 2 hours and i can't figure it out yet it seems so simple.

Question: In this exercise, you modify one of the Waterson Company applications from this chapters Apply lesson. Use Windows to make a copy of the Waterson Solution-Highest folder. Rename the copy Waterson Solution-Highest-DoLoop. Open the Waterson Solution.sln file contained in the Waterson Solution-Highest-DoLoop folder. Change the For...Next statement in the btnDisplay_Click procedure to the Do...Loop statement. Save the solution and then start and test the application.

Code I have so far:

Option Explicit On Option Strict On Option Infer Off

Public Class frmMain

' Class-level array. Private dblPrices() As Double = {85.7, 89.5, 91, 99, 97.5, 96, 96.8, 96.8, 96, 99}

Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load ' Fills list box with prices.

For Each dblStockPrice As Double In dblPrices lstPrices.Items.Add(dblStockPrice.ToString("N2")) Next dblStockPrice End Sub

Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click ' Displays the highest stock price and the number of days at that price.

' Declare variables. Dim intlastsub As Integer = dblPrices.GetUpperBound(0) Dim dblHighest As Double = dblPrices(0) Dim intDays As Integer = 1 Dim intSub As Integer = 1

Do While intSub = intlastsub dblHighest = dblPrices(intSub) intDays += 1 Do While dblPrices(intSub) > dblHighest dblHighest = dblPrices(intSub) intDays = 1 Loop intSub += 1 Loop

lblHighest.Text = dblHighest.ToString("C2") lblDays.Text = intDays.ToString End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click Me.Close() End Sub End Class

For some reason I can't post the output as a picture but

My current output What I need to get

99.00 highest price textbox 99.00 highest price textbox

1 number of Days textbox 2 Days textbox

The bolded area in the code needs me to change the code from (For next loop) to a (Do Loop).

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!