Sod Project

Burke, Brendan J 141 Reputation points
2022-05-09T00:48:01.897+00:00

199930-sod-solution-instruction-document.jpg200061-sod-solution-designer-window.jpg200023-sod-solution-code-editor-window.jpg199957-example-of-answer.jpg200046-answer-im-getting.jpg

Basically The problem is that the answer I'm getting is not the same as the example of the answer I provided or similar. I just need the code so that when I enter any length, any width, any price of sod I should be getting a total price not a blank in the total price and $0.00 in the sod price text box? I just need the correct code to be able to run this application the way it wants me to. specifically for the part in question 4 that says A Calculate button that when clicked determines the total cost of laying sod based upon the three values entered by the user. The three values are Length, Width, Sod Price

This is the code I have at the moment.

Public Class frmMain  
  
    'creating object of rectangle  
    Dim rectangle As New Rectangle()  
  
    Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalc.Click  
        Dim Length As Integer  
        Dim Width As Integer  
  
        Dim rect As New Rectangle(Length, Width)  
  
        Dim area As Integer = rect.GetArea()  
  
        Dim Price As Double  
        'Since the area is in sq feet and price is given per sq yards         
        'We'll convert sq feet to sq yard, by dividing by 9  
        Dim areaInSqYd As Double = area / 9  
  
        Dim totalPrice As Double = areaInSqYd * Price  
  
        'Call the sub routine updatedisplayTotalPrice to update the text.  
        updatedisplayTotalPrice(totalPrice)  
        'Displays the total price in proper currency format  
        txtPrice.Text = String.Format("{0:C2}", totalPrice)  
  
    End Sub  
    Private Sub updatedisplayTotalPrice(ByVal totalPrice As Double)  
  
    End Sub  
  
  
    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click  
        Me.Close()  
    End Sub  
  
End Class  
  
  

Thanks

Developer technologies | VB
{count} votes

Answer accepted by question author
  1. Jiachen Li-MSFT 34,231 Reputation points Microsoft External Staff
    2022-05-09T01:32:24.047+00:00

    Hi @Burke, Brendan J ,
    You forgot to get length, width, price from TextBoxs.

             Dim Length As Integer = TextBoxLength.Text  
             Dim Width As Integer = TextBoxWidth.Text  
             Dim Price As Double = TextBoxPrice.Text  
    

    Best Regards.
    Jiachen Li

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Ken Tucker 5,861 Reputation points
    2022-05-09T01:02:39.777+00:00

    It looks like this function should display the price

     Private Sub updatedisplayTotalPrice(ByVal totalPrice As Double)
    
     End Sub
    

    but there is no code in it. You would need to set the control which displays the total price text property to totalPrice

     myControl.Text = totalPrice.ToString("c")
    
    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.